What will be the output of the program?
int i = (int) Math.random();
Which of the following would compile without error?
Which of the following are valid calls to Math.max?
String d = "bookkeeper"; d.substring(1,7); d = "w" + d; d.append("woo"); /* Line 4 */ System.out.println(d);
public class BoolTest { public static void main(String [] args) { int result = Boolean b1 = new Boolean("TRUE"); Boolean b2 = new Boolean("true"); Boolean b3 = new Boolean("tRuE"); Boolean b4 = new Boolean("false"); if (b1 == b /* Line*/ result = if (b1.equals(b) /* Line*/ result = result + if (b2 == b /* Line*/ result = result + if (b2.equals(b) /* Line*/ result = result + if (b2.equals(b) /* Line*/ result = result + System.out.println("result = " + result); } }
Which of the following will produce an answer that is closest in value to a double, d, while not being greater than d?
String a = "newspaper"; a = a.substring(5,7); char b = a.charAt(1); a = a + b; System.out.println(a);
public class StringRef { public static void main(String [] args) { String s1 = "abc"; String s2 = "def"; String s3 = s /* Line 7 */ s2 = "ghi"; System.out.println(s1 + s2 + s3); } }
class A { public A(int x){} } class B extends A { } public class test { public static void main (String args []) { A a = new B(); System.out.println("complete"); } }
String a = "ABCD"; String b = a.toLowerCase(); b.replace('a','d'); b.replace('b','c'); System.out.println(b);
public class ObjComp { public static void main(String [] args ) { int result = ObjComp oc = new ObjComp(); Object o = oc; if (o == oc) result = if (o != oc) result = result + if (o.equals(oc) ) result = result + if (oc.equals(o) ) result = result + System.out.println("result = " + result); } }
What two statements are true about the result obtained from calling Math.random()?
String s = "ABC"; s.toLowerCase(); s += "def"; System.out.println(s);
int i =j = do { if(i++ > --j) /* Line 4 */ { continue; } } while (i < 5); System.out.println("i = " + i + "and j = " + j); /* Line 9 */
public class ExamQuestion{ static int x; boolean catch() { x++; return true; } public static void main(String[] args) { x= if ((catch() | catch()) || catch()) x++; System.out.println(x); } }
public class Example { public static void main(String [] args) { double values[] = {-2.-1.0.4}; int cnt = for (int x=x < values.length; x++) { if (Math.round(values[x] + .== Math.ceil(values[x])) { ++cnt; } } System.out.println("same results " + cnt + " time(s)"); } }
Please disable the adBlock and continue. Thank you.