Question Number 1
Which code segment could execute the stored procedure "countRecs()" located in a database server?
Choice 1
Statement stmt = connection.createStatement();
stmt.execute("COUNTRECS()");
Choice 2
CallableStatement cs = con.prepareCall("{call COUNTRECS}");
cs.executeQuery();
Choice 3
StoreProcedureStatement spstmt = connection.createStoreProcedure("countRecs()");
spstmt.executeQuery();
Choice 4
PrepareStatement pstmt = connection.prepareStatement("countRecs()");
pstmt.execute();
Choice 5
Statement stmt = connection.createStatement();
stmt.executeStoredProcedure("countRecs()");
------------------------------------------------------------
Question Number 2
if(check4Biz(storeNum) != null) {}
Referring to the above, what datatype could be returned by method check4Biz()?
Choice 1
Boolean
Choice 2
int
Choice 3
String
Choice 4
char
Choice 5
byte
------------------------------------------------------------
Question Number 3
int j;
for(int i=0;i<14;i++) {
if(i<10) {
j = 2 + i;
}
System.out.println("j: " + j + " i: " + i);
}
What is WRONG with the above code?
Choice 1
Integer "j" is not initialized.
Choice 2
Nothing.
Choice 3
You cannot declare integer i inside the for-loop declaration.
Choice 4
The syntax of the "if" statement is incorrect.
Choice 5
You cannot print integer values without converting them to strings.
------------------------------------------------------------
Question Number 4
Which one of the following is a valid declaration of an applet?
Choice 1
Public class MyApplet extends java.applet.Applet {
Choice 2
Public Applet MyApplet {
Choice 3
Public class MyApplet extends applet implements Runnable {
Choice 4
Abstract class MyApplet extends java.applet.Applet {
Choice 5
Class MyApplet implements Applet {
------------------------------------------------------------
Question Number 5
int values[] = {1,2,3,4,5,6,7,8};
for(int i=0;i< X; ++i)
System.out.println(values[i]);
Referring to the above, what value for X will print all members of array "values"?
Choice 1
1
Choice 2
7
Choice 3
8
Choice 4
9
Choice 5
None, since there is a syntax error in the array declaration
------------------------------------------------------------
Question Number 6
public int m1(int x) {
int count=1;
try {
count += x;
count += m2(count);
count++;
}
catch(Exception e) { count -= x; }
return count;
}
Referring to the above, when m1(2) is invoked, m2() throws an ArithmeticException and m1() returns which one of the following?
Choice 1
1
Choice 2
2
Choice 3
3
Choice 4
4
Choice 5
The system will exit
------------------------------------------------------------
Question Number 7
System.getProperties().put(
"java.rmi.server.codebase",
"
http://www.domain.com/classes/");
Which one of the following is a capability of the above code?
Choice 1
Override CLASSPATH
Choice 2
Register an rmi server on its host system
Choice 3
Set the location of all applets in a web server
Choice 4
Append CLASSPATH
Choice 5
Facilitate dynamic class loading for remote objects
------------------------------------------------------------
Question Number 8
Which one of the following statements is FALSE?
Choice 1
Java supports multi-threaded programming.
Choice 2
Threads in a single program can have different priorities.
Choice 3
Multiple threads can manipulate files and get user input at the same time.
Choice 4
Two threads can never act on the same object at the same time.
Choice 5
Threads are created and started with different methods.
------------------------------------------------------------
Question Number 9
1 public static void main(String[] s) {
2 String n1, n2, n3;
3 n1 = "n1";
4 n2 = "n2";
5 n3 = "n3";
6 {
7 String n4 = "inner";
8 n2 = n1;
9 }
10 n3 = null;
11 }
How many instances of the String will be eligible for garbage collection after line 10 in the above code snippet is executed?
Choice 1
0
Choice 2
1
Choice 3
2
Choice 4
3
Choice 5
The code will not compile.
------------------------------------------------------------
Question Number 10
Which code declares class A to belong to the mypackage.financial package?
Choice 1
package mypackage;
package financial;
Choice 2
import mypackage.*;
Choice 3
package mypackage.financial.A;
Choice 4
import mypackage.financial.*;
Choice 5
package mypackage.financial;