Consider two boolean variables a and b. Which of the following best refactors this code?
cs-2 sb-1-Study Guide - More Advanced Javaimg_no 9.jpg
  • if(a && b) System.out.println("a");
  • if(a || b) System.out.println("a");
  • if(a) System.out.println("a");
  • if(b) System.out.println("b");
Consider two boolean variables a and b. Which of the following best refactors this code?
cs-2 sb-1-Study Guide - More Advanced Javaimg_no 10.jpg
  • if(b) System.out.println(a?"b":"a");
  • if(b) System.out.println(a?"a":"b");
  • if(a) System.out.println(b?"b":"a");
  • if(a) System.out.println(b?"a":"b");
Consider three boolean variables a, b, and c. Which of the following best refactors this code?
cs-2 sb-1-Study Guide - More Advanced Javaimg_no 11.jpg
  • if(a?b:c) System.out.println("Hello!");
  • if((a && b) || (!a && c)) System.out.println("Hello!");
  • if(b || c) System.out.println("Hello!");
  • 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?
cs-2 sb-1-Study Guide - More Advanced Javaimg_no 12.jpg
  • if(a && (b==c)) System.out.print("Hello!");
  • if(a && ((b&&c) || !b)) System.out.print("Hello!");
  • if(a && ((b&&c) || (!b&&!c))) System.out.print("Hello!");
  • if((b&&c) || !b) System.out.print("Hello!");
Consider three boolean variables a, b, and c. Which of the following best refactors this code?
cs-2 sb-1-Study Guide - More Advanced Javaimg_no 13.jpg
  • if(a && (b==c)) System.out.println(b?"Hello!":"Goodbye.");
  • if(a) {if(b&&c) System.out.println("Hello!");else if(!b && !c) System.out.println("Goodbye.");},
  • if(a && ((b&&c) || !c)) System.out.println(c?"Hellol":"Goodbye.");
  • 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?
  • Square u = s; s = t; t = u;
  • Square u = s; t = u; s = t;
  • Square u = t; s = u; t = s;
  • 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?
  • ChessPiece m = k; k = null; f(); k = m;
  • k = null; f(); k = m;
  • ChessPiece m = k; f(); k = m;
  • ChessPiece m; k = m; f(); m = k;
0:0:1



Answered

Not Answered

Not Visited
Correct : 0
Incorrect : 0