java-programming-java-lang-class Related Question Answers

26. What will be the output of the program? public class Test { public static void main(String[] args) { final StringBuffer a = new StringBuffer(); final StringBuffer b = new StringBuffer(); new Thread() { public void run() { System.out.print(a.append("A")); synchronized(b) { System.out.print(b.append("B")); } } }.start(); new Thread() { public void run() { System.out.print(b.append("C")); synchronized(a) { System.out.print(a.append("D")); } } }.start(); } }





27. What will be the output of the program? String s = "hello"; Object o = s; if( o.equals(s) ) { System.out.println("A"); } else { System.out.println("B"); } if( s.equals(o) ) { System.out.println("C"); } else { System.out.println("D"); } A B C D





28. What will be the output of the program (in jdk1.6 or above)? public class BoolTest { public static void main(String [] args) { Boolean b1 = new Boolean("false"); boolean b2; b2 = b1.booleanValue(); if (!b2) { b2 = true; System.out.print("x "); } if (b1 & b2) / Line 13 / { System.out.print("y "); } System.out.println("z"); } }





29. Which statement is true given the following? Double d = Math.random();





30. Which two statements are true about wrapper or String classes? If x and y refer to instances of different wrapper classes, then the fragment x.equals(y) will cause a compiler failure. If x and y refer to instances of different wrapper classes, then x == y can sometimes be true. If x and y are String references and if x.equals(y) is true, then x == y is true. If x, y, and z refer to instances of wrapper classes and x.equals(y) is true, and y.equals(z) is true, then z.equals(x) will always be true. If x and y are String references and x == y is true, then y.equals(x) will be true.





31. Which of the following will produce an answer that is closest in value to a double, d, while not being greater than d?





32. What two statements are true about the result obtained from calling Math.random()? The result is less than 0.0. The result is greater than or equal to 0.0.. The result is less than 1.0. The result is greater than 1.0. The result is greater than or equal to 1.0.





33. What is the value of "d" after this line of code has been executed? double d = Math.round ( 2.5 + Math.random() );





34. Which of the following would compile without error?





35. Which of the following are valid calls to Math.max? Math.max(1,4) Math.max(2.3, 5) Math.max(1, 3, 5, 7) Math.max(-1.5, -2.8f)





36. public class Myfile { public static void main (String[] args) { String biz = args[1]; String baz = args[2]; String rip = args[3]; System.out.println("Arg is " + rip); } } Select how you would start the program to cause it to print: Arg is 2





Terms And Service:We do not guarantee the accuracy of available data ..We Provide Information On Public Data.. Please consult an expert before using this data for commercial or personal use | Powered By:Omega Web Solutions
© 2002-2017 Omega Education PVT LTD...Privacy | Terms And Conditions
Question ANSWER With Solution