What is the result?

Given:public class Vowel { private char var;public static void main(String[] args) { char var1 = 1 a 1 ; char var2 = varl; var2 = 1 e 1 ;Vowel obj1 = new Vowel ();Vowel obj2 = objl; obj1.var = 1 i 1 ; obj 2.var = ‘o’;System.out.println(varl + “, ” +var2);System.out.print(obj1.var + “, ” +obj2.var);}}What … Read more

Which statement is true about the switch statement?

Which statement is true about the switch statement?Reference http://www.dummies.com/proaramming/iava/switch-statements-in-iava/ Question: Which statement is true about the switch statement? Options: It must contain the default section. The break statement, at the end of each case block, is mandatory. Its case label literals can be changed at runtime. Its expression must evaluate to a single value. Correct … Read more

What is the result?

Given:class Caller {private void init () {System.out.println(“Initialized”);}private void start () {init(];System.out.println(“Started”) ;}public class TestCall {public static void main(String[] args) { Caller c – new Caller(); c.start (); c.init();}}What is the result? Question: What is the result? Options: An exception is thrown at runtime. Initialized Started Initialized Initialized Started Compilation fails. Correct Answer The Correct Answer … Read more

Which statement will empty the contents of a StringBuilder variable named sb?

Which statement will empty the contents of a StringBuilder variable named sb? Question: Which statement will empty the contents of a StringBuilder variable named sb? Options: sb. deleteAII 0; sb. delete (0, sb. size 0); sb. delete (0, sb. length 0); sb. removeAII 0; Correct Answer The Correct Answer for this Question is sb. delete … Read more

Which statement best describes encapsulation?

Which statement best describes encapsulation?Explanation/Reference: Question: Which statement best describes encapsulation? Options: Encapsulation ensures that classes can be designed so that only certain fields and methods of an object are accessible from other objects. Encapsulation ensures that classes can be designed so that their methods are inheritable. Encapsulation ensures that classes can be designed with … Read more

Which modification enables the code to compile?

Given the code fragments:A.java:package pi; public class A {}B.java:package pl.p2;//line nl public class B {public void doStuff() {A b = new A () i}}C.java:package p3;//line n2 public class C {public static void main(String[] args) { A o1 = new A(};B o2 = new B(};>}Which modification enables the code to compile?Replace line n2 with: import p1 … Read more

What is the result?

Given the code fragment:int n [] [] = {{1, 3}, {2, 3}};for (int i = n.length-1; i >= 0; i—) {for (int y : n[i]) {System.out.print (y) ;}}What is the result? Question: What is the result? Options: 1324 413 3142 4231 Correct Answer The Correct Answer for this Question is 3142

Which is true about the switch statement?

Correct Answer for the Question – Which is true about the switch statement? is given below Which is true about the switch statement? Its expression can evaluate to a collection of values. The break statement, at the end of each case block, is optional. Its case label literals can be changed at runtime. It must contain … Read more