Professional Documents
Culture Documents
A. weakly typed
B. strogly typed
C. moderate typed
D. None of these
Answer: Option B
2.
A. 6
B. 7
C. 8
D. 9
Answer: Option C
3.
B. unsigned
C. Both of the above
D. None of these
Answer: Option A
4.
B. 32 bit
C. 64 bit
Answer: Option B
The smallest integer type is ......... and its size is ......... bits.
A. short, 8
B. byte, 8
C. short, 16
D. short, 16
Answer: Option B
B. It can extend exactly one class and can implement multiple interfaces.
A. You must have a reference to an instance of the enclosing class in order to instantiate it.
which statement, if placed in a class other than MyOuter or MyInner, instantiates an instance of
the nested class?
A. MyOuter.MyInner m = new MyOuter.MyInner();
B. after line 6
C. after line 7
class HappyGarbage01
{
public static void main(String args[])
{
HappyGarbage01 h = new HappyGarbage01();
h.methodA(); /* Line 6 */
}
Object methodA()
{
Object obj1 = new Object();
Object [] obj2 = new Object[1];
obj2[0] = obj1;
obj1 = null;
return obj2[0];
}
}
Where will be the most chance of the garbage collector being invoked?
A. After line 9
B. After line 10
C. After line 11
At what point is the Bar object, created on line 6, eligible for garbage collection?
A. after line 12
B. after line 14
B. After line 8
D. When the instance running this code is made eligible for garbage collection.
.
class Test
{
private Demo d;
void start()
{
d = new Demo();
this.takeDemo(d); /* Line 7 */
} /* Line 8 */
void takeDemo(Demo demo)
{
demo = null;
demo = new Demo();
}
}
B. After line 8
D. When the instance running this code is made eligible for garbage collection.
Answer: Option D
public class X
{
public static void main(String [] args)
{
X x = new X();
X x2 = m1(x); /* Line 6 */
X x4 = new X();
x2 = x4; /* Line 8 */
doComplexStuff();
}
static X m1(X mx)
{
mx = new X();
return mx;
}
}
After line 8 runs. how many objects are eligible for garbage collection?
A. 0
B. 1
C. 2
D. 3
Answer: Option B
ull; /* Line 6 */
oa[0] = null; /* Line 7 */
return o; /* Line 8 */
}
When is the Float object, created in line 3, eligible for garbage collection?
A. just after line 5
after line 11 runs, how many objects are eligible for garbage collection?
A. 0
B. 1
C. 2
D. 3
Answer: Option C
What allows the programmer to destroy an object x?
A. x.delete()
B. x.finalize()
C. Runtime.getRuntime().gc()
B. after line 6
C. after line 7
At what point is the Bar object, created on line 6, eligible for garbage collection?
A. after line 12
B. after line 14
B. After line 8
D. When the instance running this code is made eligible for garbage collection.
Answer: Option D
public class X
{
public static void main(String [] args)
{
X x = new X();
X x2 = m1(x); /* Line 6 */
X x4 = new X();
x2 = x4; /* Line 8 */
doComplexStuff();
}
static X m1(X mx)
{
mx = new X();
return mx;
}
}
After line 8 runs. how many objects are eligible for garbage collection?
A. 0
B. 1
C. 2
D. 3
Answer: Option B
public Object m()
{
Object o = new Float(3.14F);
Object [] oa = new Object[l];
oa[0] = o; /* Line 5 */
o = null; /* Line 6 */
oa[0] = null; /* Line 7 */
return o; /* Line 8 */
}
When is the Float object, created in line 3, eligible for garbage collection?
A. just after line 5
class X2
{
public X2 x;
public static void main(String [] args)
{
X2 x2 = new X2(); /* Line 6 */
X2 x3 = new X2(); /* Line 7 */
x2.x = x3;
x3.x = x2;
x2 = new X2();
x3 = x2; /* Line 11 */
doComplexStuff();
}
}
after line 11 runs, how many objects are eligible for garbage collection?
A. 0
B. 1
C. 2
D. 3
Answer: Option C
allows the programmer to destroy an object x?
A. x.delete()
B. x.finalize()
C. Runtime.getRuntime().gc()
What is the value of "d" after this line of code has been executed?
double d = Math.round ( 2.5 + Math.random() );
A. 2
B. 3
C. 4
D. 2.5
Answer: Option B
B. int b = Math.abs(5.0);
C. int c = Math.abs(5.5F);
D. int d = Math.abs(5L);
Answer: Option A
B. 2, 3 and 4
C. 1, 2 and 3
D. 3 and 4
Answer: Option A
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
A. java Myfile 222
B. java Myfile 1 2 2 3 4
C. java Myfile 1 3 2 2
D. java Myfile 0 1 2 3
Answer: Option C
* What is the value of "d" after this line of code has been executed?
double d = Math.round ( 2.5 + Math.random() );
A. 2
B. 3
C. 4
D. 2.5
Answer: Option B
B. int b = Math.abs(5.0);
C. int c = Math.abs(5.5F);
D. int d = Math.abs(5L);
Answer: Option A
B. 2, 3 and 4
C. 1, 2 and 3
D. 3 and 4
Select how you would start the program to cause it to print: Arg is 2
A. java Myfile 222
B. java Myfile 1 2 2 3 4
C. java Myfile 1 3 2 2
D. java Myfile 0 1 2 3
Answer: Option C
You want subclasses in any package to have access to members of a superclass. Which is the
most restrictive access that accomplishes this objective?
A. public
B. private
C. protected
D. transient
Answer: Option C
public class Outer
{
public void someOuterMethod()
{
//Line 5
}
public class Inner { }
B. 2 and 3
C. 3 and 4
D. 1 and 5
Answer: Option C
Which three form part of correct array declarations?
1. public int a [ ]
2. static int [ ] a
3. public [ ] int a
4. private int a [3]
5. private int [3] a [ ]
6. public final int [ ] a
A. 1, 3, 4
B. 2, 4, 5
C. 1, 2, 6
D. 2, 5, 6
Answer: Option C
public class Test { }
B. Test(void)
C. public Test( )
D. public Test(void)
Answer: Option C
What is the most restrictive access modifier that will allow members of one class to have access
to members of another class in the same package?
A. public
B. abstract
C. protected
D. synchronized
E. default access
Answer: Option E
Which of the following is/are legal method declarations?
1. protected abstract void m1();
2. static final void m1(){}
3. synchronized public final void m1() {}
4. private native void m1();
A. 1 and 3
B. 2 and 4
C. 1 only
E. Integer results[ ]
Answer: Option B
Which three are valid method signatures in an interface?
1. private int getArea();
2. public float getVol(float x);
3. public void main(String [] args);
4. public static void main(String [] args);
5. boolean setFlag(Boolean [] test);
A. 1 and 2
B. 2, 3 and 5
C. 3, 4, and 5
D. 2 and 4
You want a class to have access to members of another class in the same package. Which is the
most restrictive access that accomplishes this objective?
A. public
B. private
C. protected
D. default access
Answer: Option D
A. int
B. byte
C. long
D. double
Answer: Option D
class A
{
protected int method1(int a, int b)
{
return 0;
}
}
Which two of the following are legal declarations for nonnested classes and interfaces?
1. final abstract class Test {}
2. public static interface Test {}
3. final public class Test {}
4. protected abstract class Test {}
5. protected interface Test {}
6. abstract public class Test {}
A. 1 and 4
B. 2 and 5
C. 3 and 6
D. 4 and 6
Answer: Option C
Which of the following class level (nonlocal) variable declarations will not compile?
A. protected int a;
B. transient int b = 3;
D. volatile int d;
Answer: Option C
B. 3, 5
C. 4, 5
D. 1, 2
Answer: Option D
Given a method in a protected class, what access modifier do you use to restrict access to
that method to only the other members of the same class?
A. final
B. static
C. private
D. protected
E. volatile
Answer: Option C
Which is a valid declaration within an interface?
A. public static short stop = 23;
Suppose that you would like to create an instance of a new Map that has an iteration order that is
the same as the iteration order of an existing instance of a Map. Which concrete implementation
of the Map interface should be used for the new instance?
A. TreeMap
B. HashMap
C. LinkedHashMap
Which class does not override the equals() and hashCode() methods, inheriting them directly
from class Object?
A. java.lang.String
B. java.lang.Double
C. java.lang.StringBuffer
D. java.lang.Character
Answer: Option C
Which collection class allows you to grow or shrink its size and provides indexed access to its
elements, but whose methods are not synchronized?
A. java.util.HashSet
B. java.util.LinkedHashSet
C. java.util.List
D. java.util.ArrayList
Answer: Option D
You need to store elements in a collection that guarantees that no duplicates are stored and all
elements can be accessed in natural order. Which interface provides that capability?
A. java.util.Map
B. java.util.Set
C. java.util.List
D. java.util.Collection
Answer: Option B
Which interface does java.util.Hashtable implement?
A. Java.util.Map
B. Java.util.List
C. Java.util.HashTable
D. Java.util.Collection
Answer: Option A
Which interface provides the capability to store objects using a key-value pair?
A. Java.util.Map
B. Java.util.Set
C. Java.util.List
D. Java.util.Collection
Answer: Option A
Which collection class allows you to associate its elements with key values, and allows you to
retrieve objects in FIFO (first-in, first-out) sequence?
A. java.util.ArrayList
B. java.util.LinkedHashMap
C. java.util.HashMap
D. java.util.TreeMap
Answer: Option B
Which collection class allows you to access its elements by associating a key with an element's
value, and provides synchronization?
A. java.util.SortedMap
B. java.util.TreeMap
C. java.util.TreeSet
D. java.util.Hashtable
Answer: Option D
B. float f = 1.0;
C. float f = "1";
D. float f = 1.0d;
Answer: Option A
/* Missing Statement ? */
public class foo
{
public static void main(String[]args)throws Exception
{
java.io.PrintWriter out = new java.io.PrintWriter();
new java.io.OutputStreamWriter(System.out,true);
out.println("Hello");
}
}
What line of code should replace the missing statement to make this program compile?
A. No statement required.
B. import java.io.*;
C. include java.io.*;
D. import java.io.PrintWriter;
Answer: Option A
B. 0 to 65535
C. -256 to 255
D. -32768 to 32767
Answer: Option B
. Which of the following are Java reserved words?
1. run
2. import
3. default
4. implement
A. 1 and 2
B. 2 and 3
C. 3 and 4
D. 2 and 4
Answer: Option B
B. start();
C. run();
D. resume();
Answer: Option B
B. 2 and 4
C. 1 and 2
D. 2 and 5
Answer: Option C
C. 1, 2, 6
D. 2, 3, 4
Answer: Option C
class X implements Runnable
{
public static void main(String args[])
{
/* Missing code? */
}
public void run() {}
}
A. foo
B. MyThread foo
C. MyThread bar
D. foo bar
Answer: Option B
A. Compilation fails
The program prints pairs of values for x and y that might not always be the same on the
C.
same line (for example, "x=2, y=1")
The program prints pairs of values for x and y that are always the same on the same line
D. (for example, "x=1, y=1". In addition, each value appears once (for example, "x=1, y=1"
followed by "x=2, y=2")
Answer: Option D
A. DeadLock
B. It print 12 12 12 12
C. Compilation Error
View Answer
Answer: Option B
C. It will print the numbers 1 to 20, but the order cannot be determined
B. 1 2 3
C. 1 3
D. 1 2
Answer: Option D
and assuming that data must be protected from corruption, what—if anything—can you add to
the preceding code to ensure the integrity of data?
A. Synchronize the run method.
new Thread()
{
public void run()
{
synchronized(this)
{
h.sb1.append("A");
h.sb2.append("B");
System.out.println(h.sb1);
System.out.println(h.sb2);
}
}
}.start();
new Thread()
{
public void run()
{
synchronized(this)
{
h.sb1.append("D");
h.sb2.append("C");
System.out.println(h.sb2);
System.out.println(h.sb1);
}
}
}.start();
}
}
A. ABBCAD
B. ABCBCAD
C. CDADACB
class Test
{
public static void main(String [] args)
{
printAll(args);
}
Each String in the array lines will output, with no pause in between because this method is
B.
not executed in a Thread.
Each String in the array lines will output, and there is no guarantee there will be a pause
C.
because currentThread() may not retrieve this thread.
C. 1..2..
D. 1..2..3..
Answer: Option C
new Thread()
{
public void run()
{
synchronized(sb1)
{
sb1.append("C");
sb2.append("D");
}
}
}.start(); /* Line 28 */
D. Cannot be determined.
Answer: Option D
. What will be the output of the program?
public class ThreadTest extends Thread
{
public void run()
{
System.out.println("In run");
yield();
System.out.println("Leaving run");
}
public static void main(String []argv)
{
(new ThreadTest()).start();
}
}
A. Compilation error.
A. The code will not compile because of an error on notify(); of class Foo.
B. The code will not compile because of some other error in class Test.
A. Compilation fails.
B. 1..2..3..
C. 0..1..2..3..
D. 0..1..2..
Answer: Option D
new Thread()
{
public void run()
{
synchronized(this)
{
h.sb1.append("A");
h.sb2.append("B");
System.out.println(h.sb1);
System.out.println(h.sb2);
}
}
}.start();
new Thread()
{
public void run()
{
synchronized(this)
{
h.sb1.append("D");
h.sb2.append("C");
System.out.println(h.sb2);
System.out.println(h.sb1);
}
}
}.start();
}
ABBCAD
B. ABCBCAD
C. CDADACB
Output
determined
D. by the
underlying
platform.
Answer: Option D
class Test
{
public static void main(String [] args)
{
printAll(args);
}
Each String in the array lines will output, with no pause in between because this method is
B.
not executed in a Thread.
Each String in the array lines will output, and there is no guarantee there will be a pause
C.
because currentThread() may not retrieve this thread.
D. 1..2..3..
Answer: Option C
new Thread()
{
public void run()
{
synchronized(sb1)
{
sb1.append("C");
sb2.append("D");
}
}
}.start(); /* Line 28 */
D. Cannot be determined.
Answer: Option D
. What will be the output of the program?
public class ThreadTest extends Thread
{
public void run()
{
System.out.println("In run");
yield();
System.out.println("Leaving run");
}
public static void main(String []argv)
{
(new ThreadTest()).start();
}
}
A. Compilation error.
A. The code will not compile because of an error on notify(); of class Foo.
B. The code will not compile because of some other error in class Test.
B. 1..2..3..
C. 0..1..2..3..
D. 0..1..2..
Answer: Option D
----------------------------------JDBC------------------------------------------------------------
In order to transfer data between a database and an application written in the
Java programming language, the JDBC API provides which of these methods?
- Published on 19 Oct 15
a. Methods on the ResultSet class for retrieving SQL SELECT results as Java types.
b. Methods on the PreparedStatement class for sending Java types as SQL
statement parameters.
c. Methods on the CallableStatement class for retrieving SQL OUT parameters as
Java types.
d. All mentioned above
a. True
b. False
Answer Explanation
ANSWER: True
Which JDBC type represents a "single precision" floating point number that supports seve
mantissa?
- Published on 19 Oct 15
a. REAL
b. DOUBLE
c. FLOAT
d. INTEGER
Answer Explanation
ANSWER: REAL
Which method is used for retrieving streams of both ASCII and Unicode characters is new in
2.0 core API?
- Published on 19 Oct 15
a. getCharacterStream
b. getBinaryStream
c. getAsciiStream
d. getUnicodeStream
Answer Explanation
ANSWER: getCharacterStream
How many Result sets available with the JDBC 2.0 core API?
- Published on 19 Oct 15
a. 2
b. 3
c. 4
d. 5
Answer Explanation
ANSWER: 3
Abbreviate the term UDA?
- Published on 19 Oct 15
a. True
b. False
Answer Explanation
ANSWER: True
Which method Drops all changes made since the previous commit/rollback?
- Published on 22 Jul 15
ANSWER: False
Which methods returns a stream that simply provides the raw bytes from the database wit
conversion?
- Published on 22 Jul 15
a. getCharacterStream
b. getBinaryStream
c. getAsciiStream
d. getUnicodeStream
Answer Explanation
ANSWER: getBinaryStream
The ACID properties does not describes the transaction management well.
- Published on 22 Jul 15
a. True
b. False
Answer Explanation
ANSWER: False
Which method is used to establish the connection with the specified url in a
Driver Manager class?
- Published on 22 Jul 15
a. CONCUR_UPDATABLE
b. CONCUR_READ_ONLY
c. All of the above
d. None of the above
Answer Explanation
ANSWER: CONCUR_READ_ONLY
Which driver Network connection is indirect that a JDBC client makes to a
middleware process that acts as a bridge to the DBMS server?
- Published on 21 Jul 15
a. JDBC-Net
b. JDBC-ODBC bridge
c. Native API as basis
d. Native protocol as basis
Answer Explanation
ANSWER: JDBC-Net
JDBC RowSet is the wrapper of ResultSet,It holds tabular data like ResultSet
but it is easy and flexible to use.
- Published on 21 Jul 15
a. True
b. False
Answer Explanation
ANSWER: True
Which kind of driver converts JDBC calls into calls on the client API for Oracle,
Sybase, Informix, IBM DB2, or other DBMS?
- Published on 20 Jul 15
a. java.sql.Statement
b. java.sql.PreparedStatement
c. All the above
d. None of the above
Answer Explanation
a. CallableStatement Interface
b. PreparedStatement Interface
c. All the above
d. None of the above
Answer Explanation
a. True
b. False
ANSWER: True.
The ResultSet.next method is used to move to the next row of the ResultSet,
making it the current row.
- Published on 20 Jul 15
a. True
b. False
Answer Explanation
ANSWER: True
The performance of the application will be faster if you use PreparedStatement
interface because query is compiled only once.
- Published on 20 Jul 15
a. True
b. False
Answer Explanation
ANSWER: True
Which JDBC type represents a 64-bit signed integer value between -
9223372036854775808 and 9223372036854775807?
- Published on 17 Jul 15
a. SMALLINT
b. BIGINT
c. TINYINT
d. INTEGER
Answer Explanation
ANSWER: BIGINT
DBC technology-based drivers generally fit into how many categories?
- Published on 17 Jul 15
a. 4
b. 3
c. 2
d. 5
Answer Explanation
ANSWER: 4
ResultSet object can be moved forward only and it is updatable.
- Published on 17 Jul 15
a. True
b. False
Answer Explanation
ANSWER: False
Which method is used for an SQL statement that is executed frequently?
- Published on 17 Jul 15
a. prepareStatement
b. prepareCall
c. createStatement
d. None of the above
Answer Explanation
ANSWER: prepareStatement
What is used to execute parameterized query?
- Published on 17 Jul 15
a. Statement interface
b. PreparedStatement interface
c. ResultSet interface
d. None of the above
Answer Explanation
a. JDBC API
b. ODBC API
c. Both A & B
d. None of the above
Answer Explanation
a. 5
b. 4
c. 3
d. 6
Answer Explanation
ANSWER: 5
Which model does a Java applet or application talks directly to the data
source?
- Published on 15 Jul 15
a. Two-tier models
b. Three-tier models
c. Both A & B
d. None of the above
Answer Explanation
a. Native-API driver
b. Network Protocol driver
c. Thin driver
d. Both B & C
Answer Explanation
a. JDBC-ODBC Bridge
b. JDBC Driver Test Suite
c. Both A & B
d. None of the above
Answer Explanation
a. Two-tier models
b. Three-tier models
c. Both A & B
d. None of the above
Answer Explanation
a. True
b. False
Answer Explanation
ANSWER: True
Which driver uses ODBC driver to connect to the database?
- Published on 10 Jul 15
a. 3
b. 2
c. 4
d. 5
Answer Explanation
ANSWER: 3
How many types of JDBC drivers are available?
- Published on 10 Jul 15
a. 3
b. 4
c. 2
d. 5
Answer Explanation
ANSWER: 4
Which result set generally does not show changes to the underlying database
that are made while it is open. The membership, order, and column values of
rows are typically fixed when the result set is created?
- Published on 10 Jul 15
a. TYPE_FORWARD_ONLY
b. TYPE_SCROLL_INSENSITIVE
c. TYPE_SCROLL_SENSITIVE
d. ALL MENTIONED ABOVE
Answer Explanation
ANSWER: TYPE_SCROLL_INSENSITIVE
JDBC is a Java API that is used to connect and execute query to the database
- Published on 10 Jul 15
a. True
b. False
Answer Explanation
ANSWER: True