1.
Public class Swap { public static void swapStrings(String x, String y){ String temp = x; x=y; y=temp; } public static void main(String[] args) { String a = "1"; String b = "2"; swapStrings(a, b); System.out.println("a="+a+" ,b="+b); }}
What will be the output when executing this main?
A. 
An exception will be thrown
B. 
C. 
“a=1 ,b=2” because strings are immutable
D. 
“a=1 ,b=2” because Java passes parameters by value
2.
Class Parent{ protected void x(){} public void y(){}}public class Child extends Parent{ public void x(){} protected void y(){}}
A. 
B. 
Compilation error – x can’t have its visibility increased
C. 
Compilation error – y can not have its visibility reduced
D. 
Compilation error – neither x nor y can have their visibility changed
3.
Following code will result in: int a = 3.5;
A. 
B. 
C. 
D. 
4.
Following code will result in: int a1 = 5; double a2 = (float) a1;
5.
Following code will result in: class A { int b = 1; public static void main(String[] args) { System.out.println("b is " + b); }}
A. 
B. 
C. 
D. 
6.
Following code will result in: class A { public static void main(String[] args) { B b = new A(); }}class B extends A {}
7.
Following code will result in: class A { public static void main(String[] args) { A a = new B(); }}class B extends A {}
8.
Methods that are marked protected can be called in any subclass of that class
9.
An abstract class can have non-abstract methods.
10.
What is an instanceof
11.
Can you compare a boolean to an integer?
12.
If class A implements an interface does it need to implement all methods of that interface?
A. 
B. 
No, not when A is abstract
13.
Integer a = new Integer(2); Integer b = new Integer(2); What happens when you do if (a==b)?
A. 
B. 
C. 
D. 
14.
Synchronized is a keyword to tell a Thread to grab an Object lock before continuing execution.
15.
Which ones does not extend java.lang.Number(you can make multiple choices)
A. 
B. 
C. 
D. 
E. 
16.
Which JDBC method is used to execute any SQL statement with a "SELECT" clause, that return the result of the query as a result set.
17.
Which JDBC method is used to execute INSERT, DELETE, UPDATE , and other SQL DDL such as CREATE, DROP TABLE.
18.
Which JDBC method is used for retrieving a string value (SQL type VARCHAR) and assigning into java String object.
19.
This method is used for retrieving the value from current row as object.
20.
The Connection.prepareStatement() method accepts a SQL query and returns a...
21.
This method returns an integer value indicating a row count.
22.
Consider the following classpublic class Test implements Runnable{ public void run() { }}Creating an instance of this class and calling its run() method will spawn a new thread.
23.
What is the result of attempting to compile and run the following code?public class Test { public static void main(String[] args){ Integer a = new Integer(4); Integer b = new Integer(8); Set hs = new HashSet(); hs.add(a); hs.add(b); hs.add(a); System.out.println(hs.size()); }}
24.
What is the result of attempting to compile and run the following code?public class Test { public static void main(String[] args){ Integer a = new Integer(4); Integer b = new Integer(8); Integer c = new Integer(4); Set hs = new HashSet(); hs.add(a); hs.add(b); hs.add(c); System.out.println(hs.size()); }}
25.
Class Figure { public void print() { System.out.println("FIGURE"); }}class Triangle extends Figure { public void print() { System.out.println("TRIANGLE"); }}public class Test { public static void main(String[] args) { Figure f1 = new Figure(); f1.print(); Figure f2 = new Triangle(); f2.print(); Triangle t = new Triangle(); t.print(); }}What will this program print out?