<?xml version="1.0"?>
<ownershipDocument>

    <schemaVersion>X0508</schemaVersion>

    <documentType>4</documentType>

    <periodOfReport>2025-08-06</periodOfReport>

    <issuer>
        <issuerCik>0001486957</issuerCik>
        <issuerName>BWX Technologies, Inc.</issuerName>
        <issuerTradingSymbol>BWXT</issuerTradingSymbol>
    </issuer>

    <reportingOwner>
        <reportingOwnerId>
            <rptOwnerCik>0001408482</rptOwnerCik>
            <rptOwnerName>Geveden Rex D</rptOwnerName>
        </reportingOwnerId>
        <reportingOwnerAddress>
            <rptOwnerStreet1>800 MAIN STREET</rptOwnerStreet1>
            <rptOwnerStreet2>4TH FLOOR</rptOwnerStreet2>
            <rptOwnerCity>LYNCHBURG</rptOwnerCity>
            <rptOwnerState>VA</rptOwnerState>
            <rptOwnerZipCode>24504</rptOwnerZipCode>
            <rptOwnerStateDescription></rptOwnerStateDescription>
        </reportingOwnerAddress>
        <reportingOwnerRelationship>
            <isDirector>1</isDirector>
            <isOfficer>1</isOfficer>
            <isTenPercentOwner>0</isTenPercentOwner>
            <isOther>0</isOther>
            <officerTitle>President and CEO</officerTitle>
        </reportingOwnerRelationship>
    </reportingOwner>

    <aff10b5One>0</aff10b5One>

    <nonDerivativeTable>
        <nonDerivativeTransaction>
            <securityTitle>
                <value>Common Stock</value>
            </securityTitle>
            <transactionDate>
                <value>2025-08-06</value>
            </transactionDate>
            <transactionCoding>
                <transactionFormType>4</transactionFormType>
                <transactionCode>S</transactionCode>
                <equitySwapInvolved>0</equitySwapInvolved>
            </transactionCoding>
            <transactionAmounts>
                <transactionShares>
                    <value>24468</value>
                </transactionShares>
                <transactionPricePerShare>
                    <value>178.9890</value>
                    <footnoteId id="F1"/>
                </transactionPricePerShare>
                <transactionAcquiredDisposedCode>
                    <value>D</value>
                </transactionAcquiredDisposedCode>
            </transactionAmounts>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>198126</value>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>D</value>
                </directOrIndirectOwnership>
            </ownershipNature>
        </nonDerivativeTransaction>
        <nonDerivativeTransaction>
            <securityTitle>
                <value>Common Stock</value>
            </securityTitle>
            <transactionDate>
                <value>2025-08-06</value>
            </transactionDate>
            <transactionCoding>
                <transactionFormType>4</transactionFormType>
                <transactionCode>S</transactionCode>
                <equitySwapInvolved>0</equitySwapInvolved>
            </transactionCoding>
            <transactionAmounts>
                <transactionShares>
                    <value>532</value>
                </transactionShares>
                <transactionPricePerShare>
                    <value>179.6898</value>
                    <footnoteId id="F2"/>
                </transactionPricePerShare>
                <transactionAcquiredDisposedCode>
                    <value>D</value>
                </transactionAcquiredDisposedCode>
            </transactionAmounts>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>197594</value>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>D</value>
                </directOrIndirectOwnership>
            </ownershipNature>
        </nonDerivativeTransaction>
    </nonDerivativeTable>

    <footnotes>
        <footnote id="F1">The price in Column 4 is a weighted average price. The shares were sold at prices ranging from $178.5450 to $179.5400 inclusive. Upon request by the SEC staff, the issuer, or any security holder of the issuer, full information regarding the number of shares purchased or sold at each separate price will be provided.</footnote>
        <footnote id="F2">The price in Column 4 is a weighted average price. The shares were sold at prices ranging from $179.5500 to $179.7500 inclusive. Upon request by the SEC staff, the issuer, or any security holder of the issuer, full information regarding the number of shares purchased or sold at each separate price will be provided.</footnote>
    </footnotes>

    <ownerSignature>
        <signatureName>/s/ Rex D. Geveden, by Theresa B. Taylor, attorney-in-fact</signatureName>
        <signatureDate>2025-08-08</signatureDate>
    </ownerSignature>
</ownershipDocument>
