Single Choice
Easy
QPredict the output of the following code snippet: String P = "20", Q ="22";
int a = Integer.parseInt(P);
int b = Integer.valueOf(Q);
System.out.println(a+""+b);
ID: #19885
Inheritance in Java (IS-A)
110 views
Question Info
#19885Q ID
EasyDifficulty
Inheritance in Java (IS-A)Topic
Your Answer
Choose the Best Option
Click any option to instantly check if you're correct.
Correct Answer
Explanation
The correct answer is:
(c) 2220
Explanation:
int a = Integer.parseInt(P);- Converts the string "20" to an integer and assigns it to variablea.int b = Integer.valueOf(Q);- Converts the string "22" to an integer and assigns it to variableb.System.out.println(a + "" + b);- Concatenates the values ofaandbas strings and prints the result. In this case, it prints "20" + "22", resulting in "2022".
Continue Practice
Share
Share This Question
Challenge a friend or share with your study group.
More from This Topic