← Back to Course

Lesson 28: Postfix Operators

Practice Questions

Question 1: Consider the following code. What value will be returned by this function? The return can be a value or, if revert, type revert.

function f() public pure returns (uint8) {
    uint8 a = 26;
    a++;
    return a;
}

Question 2: Consider the following code. What value will be returned by this function? The return can be a value or, if revert, type revert.

function f() public pure returns (uint8) {
    uint8 a = 26;
    a--;
    return a;
}

Question 3: Consider the following code. What value will be returned by this function? The return can be a value or, if revert, type revert.

function f() public pure returns (uint8) {
    uint8 a = 10;
    a++;
    a++;
    a++;
    return a;
}

Question 4: Consider the following code. What value will be returned by this function? The return can be a value or, if revert, type revert.

function f() public pure returns (uint8) {
    uint8 a = 10;
    a++;
    a--;
    a--;
    return a;
}

Question 5: Consider the following code. What value will be returned by this function? The return can be a value or, if revert, type revert.

function f() public pure returns (uint8) {
    uint8 a = 255;
    a++;
    return a;
}