Core Java - Interview Questions and Answers

141. What is the difference between prefix and postfix of -- and ++ operators?

Ans : The prefix form returns the increment or decrement operation and returns the value of the increment or decrement operation.
The postfix form returns the current value of all of the expression and then
performs the increment or decrement operation on that value.

142. What is the result of expression 5.45 + "3.2"?

The double value 8.6
The string ""8.6"
The long value 8.
The String "5.453.2"
Ans : d


Control Statements

143. What are the programming constructs?

a)True
b)False
Ans: a.

144. What is output of the above program?

Ans: The value assigned is 20.

145. The switch statement does not require a break.

a)True
b)False
Ans: b.

146. The conditional operator is otherwise known as the ternary operator.

a)True
b)False
Ans: a.

147. The while loop repeats a set of code while the condition is false.

a)True
b)False
Ans: b.

148. The do-while loop repeats a set of code at least once before the condition is tested.

a)True
b)False
Ans: a.

149. What are difference between break and continue?

Ans: The break keyword halts the execution of the current loop and forces control out of the loop.
The continue is similar to break, except that instead of halting the execution of the loop, it starts the next iteration.

150. The for loop repeats a set of statements a certain number of times until a condition is matched.

a)True
b)False
Ans: a.


Post a Comment

Mới hơn Cũ hơn