Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

TRUE OR FALSE 1.The following is a legal statement: double x = 5; 2.“”.format(“%

ID: 3587877 • Letter: T

Question

TRUE OR FALSE
1.The following is a legal statement: double x = 5;

2.“”.format(“%d %s ”,14, “shopping days left”); is a valid statement.

3.Boolean primitive variables can only be assigned values: true, false, or null.

4.Any for loop can be rewritten using a while loop.

5.Consider the statement: String S = “Out of Gas”; then the statement:
S[7] = 'g'; will change “Gas” to “gas”.

6.The protected keyword can only be applied to instance variables.

7.The constructor of the super class is only called when the constructor of the sub class explicitly calls super(); as its first line.

8.You can index into an array with a variable of type double as long as the there are no digits past the decimal point.

Explanation / Answer

Dear Student,

here are the answers...

-------------------------------------------------------------------------------------------------------------------------------------------

1.The following is a legal statement: double x = 5;

Ans: True

2."".format(“%d %s ”,14, “shopping days left”); is a valid statement.

Ans: False

3.Boolean primitive variables can only be assigned values: true, false, or null.

Ans: False

Expalnation: boolean is a primitive type, it cannot be assigned null value.

4.Any for loop can be rewritten using a while loop.

Ans: True

Explanation: Usually it is possible.

5.Consider the statement: String S = “Out of Gas”; then the statement:


S[7] = 'g'; will change “Gas” to “gas”.

Ans: False

Explanation: No, we cannot modify it, as the string literal are stored in read-only memory.

6.The protected keyword can only be applied to instance variables.

Ans: True

7.The constructor of the super class is only called when the constructor of the sub class explicitly calls super(); as its first line.

Ans: Not sure

8.You can index into an array with a variable of type double as long as the there are no digits past the decimal point.

Ans: False

Explantion: It should be int, practically its not possible

-----------------------------------------------------------------------------------------------------------------------------------------

Kindly Check and Verify Thanks...!!!