MCQExams
0:0:1
CBSE
JEE
NTSE
NEET
Practice
Homework
×
Computer Science
Study Guide - More Advanced Java
Consider two boolean variables a and b. Which of the following best refactors this code?
Report Question
0%
if(a && b) System.out.println("a");
0%
if(a || b) System.out.println("a");
0%
if(a) System.out.println("a");
0%
if(b) System.out.println("b");
Consider two boolean variables a and b. Which of the following best refactors this code?
Report Question
0%
if(b) System.out.println(a?"b":"a");
0%
if(b) System.out.println(a?"a":"b");
0%
if(a) System.out.println(b?"b":"a");
0%
if(a) System.out.println(b?"a":"b");
Consider three boolean variables a, b, and c. Which of the following best refactors this code?
Report Question
0%
if(a?b:c) System.out.println("Hello!");
0%
if((a && b) || (!a && c)) System.out.println("Hello!");
0%
if(b || c) System.out.println("Hello!");
0%
if(b?a:c&&!a) System.out.println("Hello!");
Consider three boolean variables a, b, and c. Which of the following best refactors this code?
Report Question
0%
if(a && (b==c)) System.out.print("Hello!");
0%
if(a && ((b&&c) || !b)) System.out.print("Hello!");
0%
if(a && ((b&&c) || (!b&&!c))) System.out.print("Hello!");
0%
if((b&&c) || !b) System.out.print("Hello!");
Consider three boolean variables a, b, and c. Which of the following best refactors this code?
Report Question
0%
if(a && (b==c)) System.out.println(b?"Hello!":"Goodbye.");
0%
if(a) {if(b&&c) System.out.println("Hello!");else if(!b && !c) System.out.println("Goodbye.");},
0%
if(a && ((b&&c) || !c)) System.out.println(c?"Hellol":"Goodbye.");
0%
if(a) {if((b&&c) || !c) System.out.println(c?"Hello!":"Goodbye.");},
Consider two Squares s and t. Which of the following will swap the values of s and t?
Report Question
0%
Square u = s; s = t; t = u;
0%
Square u = s; t = u; s = t;
0%
Square u = t; s = u; t = s;
0%
Square u = t; t = u; s = t;
Consider a ChessPiece k. Suppose as part of a routine which calculates chess moves, k must be temporarily deleted before calling function f(), and then restored afterward. Which of the following will do this?
Report Question
0%
ChessPiece m = k; k = null; f(); k = m;
0%
k = null; f(); k = m;
0%
ChessPiece m = k; f(); k = m;
0%
ChessPiece m; k = m; f(); m = k;
0:0:1
1
2
3
4
5
6
7
1
2
3
4
5
6
7
0
Answered
0
Not Answered
0
Not Visited
Correct : 0
Incorrect : 0
Report Question
×
What's an issue?
Question is wrong
Answer is wrong
Other Reason
Want to elaborate a bit more? (optional)
Support mcqexams.com by disabling your adblocker.
×
Please disable the adBlock and continue.
Thank you.
Reload page