Tag Archives: quot

Given the code fragment: String name = "Spot"; int age = 4; String str ="My dog " + name + " is " + age;

Given the code fragment:String name = “Spot”;int age = 4;String str =”My dog ” + name + ” is ” + age;System.out.println(str);AndStringBuilder sb = new StringBuilder();Using StringBuilder, which code fragment is the best potion to build and print the followingstring My dog Spot is 4 A. sb.append(“My dog “).append( name ).append(” is ” ).append(age); System.out.println(sb); B. sb.insert(“My dog… Read More »

Given: class Base { public static void main(String[] args) { System.out.println("Base " + args[2]); }

Given: class Base {public static void main(String[] args) {System.out.println(“Base ” + args[2]);}}public class Sub extends Base{public static void main(String[] args) {System.out.println(“Overriden ” + args[1]);}}And the commands:javac Sub.javajava Sub 10 20 30What is the result? A. Overridden 20 B. Base 30 Overridden 20 C. Base 30 D. Overridden 20 Base 30 Correct Answer: A

Given the code fragment: int b = 3; if ( !(b > 3)) { System.out.println("square "); }{ System.out.println("circle

Given the code fragment:int b = 3;if ( !(b > 3)) {System.out.println(“square “);}{System.out.println(“circle “);}System.out.println(“…”);What is the result? A. circle… B. square… C. Compilation fails. D. squarecircle… Correct Answer: D

Consider this method declaration: (Exhibit) A) "SET SESSION AUTHORIZATION " + user B) "SET SESSION AUTHORIZATION

Consider this method declaration:A) “SET SESSION AUTHORIZATION ” + userB) “SET SESSION AUTHORIZATION ” + stmt.enquoteIdentifier(user)Is A or B the correct replacement for <EXPRESSION> and why? A. B, because all values provided by the calling code should be enquoted. B. A, because it is unnecessary to enclose identifiers in quotes. C. A, because it sends exactly the value… Read More »