Java CTS Dumps 5
Java CTS Dumps 5
Java CTS Dumps 5
Which of the following will be the output for the above given program? (Choose
2)
An application needs to write a log file on the sequence of actions it takes while
running.
Which of the following stream classes can be used to implement the above
requirement?
Answer: a. FileOutputStream
b. LogWriter
c. PrintWriter
d. OutputStream
e. Writer
import java.io.*;
Which of the following when substituted in place of commented lines (// Line 1,
Line 2 and Line 3) produce the desired output?
5 What of the following is the default Scroll type for a ResultSet object?
Answer: a. ResultSet.TYPE_SCROLL_SENSITIVE
b. ResultSet.TYPE_SCROLLABLE
c. ResultSet.TYPE_SCROLL_INSENSITIVE
d. ResultSet.TYPE_FORWARD_ONLY
e. ResultSet.TYPE_SCROLL_BIDIRECTIONAL
import java.io.*;
b. Reads the text from keyboard and prints the same to the
console on pressing Ctrl Z, flushes (erases) the same from the
console.
c. Reads the text from keyboard line by line and prints the same
to the console on pressing ENTER key at the end of every line
d. Reads the text from keyboard and prints the same to the
console on pressing Ctrl Z
e. Reads the text from keyboard line by line and prints the same
to the console on pressing ENTER key at the end of every line,
then the same is flushed (erased) from the console.
7 A monitor called 'mon' has 5 threads in its waiting pool; all these waiting
threads have the same priority. One of the threads is thread1. How can you
notify thread1 so that it alone moves from Waiting state to Ready State?
import java.util.*;
Answer: a. Size: 64
b. Size: 44
c. Size: 66
d. Compilation error
e. Size: 46
class GC2 {
public GC2 getIt(GC2 gc2) {
return gc2;
}
c = g.getIt(c);
}
}
Answer: a. two
b. none of the objects are eligible
c. three
d. four
e. one
b. 1. setUp() method
2. tearDown() method
3. All testXXX() methods
d. 1. setUp() method
2. All testXXX() methods
3. tearDown() method
class TM {
public static void main(String a[]) {
System.out.println(a[0]+a[0].length()+a.length);
}
}
Which of the following statement is True regarding the above given code?
b. tab character
d. space character
Which of the following option will be the output for the above code snippet?
d. Compilation Error
package com.java.test;
public class A {
public void m1() {System.out.print("A.m1, ");}
protected void m2() {System.out.print("A.m2, ");}
private void m3() {System.out.print("A.m3, ");}
void m4() {System.out.print("A.m4, ");}
}
class B {
public static void main(String[] args) {
A a = new A();
a.m1(); // 1
a.m2(); // 2
a.m3(); // 3
a.m4(); // 4
}
}
Assume that both of the above classes are stored in a single source file called
'A.java'. Which of the following gives the valid output of the above code?
b. Compile-time error at 4.
c. Compile-time error at 3.
d. Compile-time error at 2.
e. Compile-time error at 1.
import java.util.*;
Which of the following code snippets when replaced at the line marked //Line 1,
will make the ArrayList a to accept only Wrapper types of primitive numerics?
b. Type II driver
c. Type I driver
19 Which of the following statements are true about String Arrays? (Choose 2)
b. String[][] s;
Answer: a. Prints: EQ
b. Prints: equals
d. Prints: equals EQ
class One {
public One() {
System.out.print(1);
}
}
class Two extends One {
public Two() {
System.out.print(2);
}
}
class Three extends Two {
public Three() {
System.out.print(3);
}
}
public class Numbers {
public static void main(String[] argv) {
new Three();
}
}
Which of the following will be the output for the above program?
Answer: a. 3
b. No output
c. 321
d. 32
e. 123
Which of the following gives the correct output for the above code?
b. Prints: 20, 40
Which of the following gives the valid ouptut for the above code?
Which of the following code when substituted to the commented line (//Insert
Code) will make the program to execute properly?
Answer: a. t.join()
b. t.start()
d. t.run()
e. t.sleep(1000)
25 Which of the following options give the names of the data structures that can
be used for Range-View operations, but no nulls?(choose 2)
Answer: a. SortedSet
b. List
c. Map
d. Vector
package com.packageone;
public class A {
private int x;
public A(int x) {
this();
this.x = x;
}
package com.packagetwo;
import com.packageone.A;
class B extends A {
B(int x) {
super(x);
}
void print() {
System.out.println(x);
}
}
class C {
public static void main(String args[]) {
A a = new B(10);
}
}
Which of the following changes will make the code to run properly? (Choose 3)
27 Which of the following classes is used to handle the abnormal situation that
may occur during database calls using JDBC API?
Answer: a. SQLException
b. Driver
c. Connection
d. DriverManager
e. Statement
Which of the following gives the output for the above given code?
b. Compilation Error
c. Runtime Error
Answer: a. classes
b. fields
c. jar files
d. class files
e. methods
i. Instance Block
ii. main() method
iii. Static Block
iv. Default Constructor of A
b. iii, i, ii, iv
d. i, iv, iii, ii
interface InterfaceOne {
int ID = 10;
int getAccess();
}
interface InterfaceTwo {
int ID = 20;
int getAccess();
}
Which of the following will be the output for the above code snippet?
Answer: a. 10
10
b. 10
20
d. 20
10
e. 20
20
class Planet { }
class Earth extends Planet { }
b. Compilation fails
c. Welcome!
d. Planet!
c. Prints: 4
package test;
class Target {
String name = "hello";
}
Which of the following options are valid that can directly access and change the
value of the variable 'name' in the above code? (Choose 2)
c. any class
38 Which of the following is the process of creating a new class from an existing
class?
Answer: a. Polymorphism
b. Inheritance
c. Abstraction
d. Reusability
Which of the following options gives the exact meaning of the method call
s1.retainAll(s2)?
Which of the following gives the line in the above program that will result in
error?
Answer: a. Line 4
b. Line 7
c. Line 6
d. Line 3
e. Line 5
Answer: a. @Override
b. @Documented
c. @Comment
d. @Deprecated
42 Consider there are two threads, "Thread A" and "Thread B". "Thread A" holds a
lock on "Object X". "Thread B" is blocked inside a wait call on Object X.
c. Thread A is interrupted.
d. Thread B is interrupted.
e. Thread B releases the lock on object X and calls the notify()
method on thread
d. It is polymorphic