What is the output of the following code?public class Test { public static void main(String[] args) { String s1 = new String(“Welcome to Java!”); String s2 = new String(“Welcome to Java!”); if (s1.equals(s2)) System.out.println(“s1 and s2 have the same contents”); else System.out.println(“s1 and s2 have different contents”); }}
Analyze the following code:public class Test { int x; public…
Analyze the following code:public class Test { int x; public Test(String t) { System.out.println(“Test”); } public static void main(String[] args) { Test test = new Test(); System.out.println(test.x); }}
What is displayed by the following code? System.out.print(“H…
What is displayed by the following code? System.out.print(“Hi, ABC, good”.matches(“ABC “) + ” “); System.out.println(“Hi, ABC, good”.matches(“.*ABC.*”));
What exception type does the following program throw?public…
What exception type does the following program throw?public class Test { public static void main(String list = new int; System.out.println(list); }}
BigInteger and BigDecimal are immutable.
BigInteger and BigDecimal are immutable.
Suppose TestSimpleCircle and SimpleCircle in Listing 9.1 are…
Suppose TestSimpleCircle and SimpleCircle in Listing 9.1 are in two separate files named TestSimpleCircle.java and SimpleCircle.java, respectively. What is the outcome of compiling TestsimpleCircle.java and then SimpleCircle.java?
Which statements are most accurate regarding the following c…
Which statements are most accurate regarding the following classes?class A { private int i; protected int j;}class B extends A { private int k; protected int m; // some methods omitted}
What is the output of the second println statement in the ma…
What is the output of the second println statement in the main method?public class Foo { int i; static int s; public static void main(String[] args) { Foo f1 = new Foo(); System.out.println(“f1.i is ” + f1.i + ” f1.s is ” + f1.s); Foo f2 = new Foo(); System.out.println(“f2.i is ” + f2.i + ” f2.s is ” + f2.s); Foo f3 = new Foo(); System.out.println(“f3.i is ” + f3.i + ” f3.s is ” + f3.s); } public Foo() { i++; s++; }}
Which of the following can be placed in the blank line in th…
Which of the following can be placed in the blank line in the following code? private int id; public void m1() { ________.id = 45; }}
Which method can be used to write data?
Which method can be used to write data?