Q1:
Which of the following keywords are used to control access to a class
member?
(A) default
(B) abstract
(C) protected
(D) interface
(E) public
• (C) & (E)
• (B), (C) & (E)
• (A), (C) & (E)
• All of these.
(B), (C) & (E)
Q8: modified
Which of the following statements about abstract methods/classes in Java
are true?
1. An abstract class cannot be instantiated.
2. Constructors cannot be abstract.
3. A subclass of an abstract class must defined the abstract methods.
4. Static methods may be declared abstract.
• Line 1, line 2 and line 3 only
• Line 1 only
• Line 1 and line 2 only
• Line 2 only
• All are true
Line 1 and line 2 only
q9:
Which of the following defines a legal abstract class?
1. class Vehicle {<br>
abstract void display(); }
2. abstract Vehicle {<br>
abstract void display(); }
3. class abstract Vehicle {<br>
abstract void display(); }
4. abstract class Vehicle {<br>
abstract void display(); {<br>
[Link]("Car"); }}
5. abstract class Vehicle {<br>
abstract void display(); }
abstract class Vehicle {<br>
abstract void display(); }
Q13:
Which keyword can protect a class in a package from accessibility by the
classes outside the package?
1. private
2. don't use any keyword at all (make it default)
3. protected
4. final
don't use any keyword at all (make it default)
Q2
Which four options describe the correct default values for array elements
of the types indicated?
A. int -> 0
B. String -> "null"
C. Dog -> null
D. char -> '\u0000'
E. float -> 0.0f
F. boolean -> true
1. A, B, C, D
2. A, C, D, E
3. B, D, E, F
4. C, D, E, F
Q3
Which three are valid declarations of a char?
A. char c1 = 064770;
B. char c2 = 'face';
C. char c3 = 0xbeef;
D. char c4 = \u0022;
E. char c5 = '\iface';
F. char c6 = '\uface';
1. 1, 2, 4
2. 1, 3, 6
3. 3, 5
4. 5 only
q4
A method that is used to assign values to the instance variables of a
class is called a
Answer
1. set method
2. get method
3. constructor
4. toString() method
q5
A / An ________ variable is shared by all instances of the class. It
exists even before an object is created.
Answer
1. instance
2. abstract
3. interface
4. static
Q15
The class [Link] .Exception is
[Link]
2. extends Throwable
3. implements Throwable
4. serializable
Q23
Which of the following is not a method of the Thread Class
1. public void run()
2. public void start()
3. public void exit()
4. public final int getPriority()
q7
What happens in a method if an unchecked exception is thrown in a try
block and there is no matching catch block?
Answer
1. The program ignores the exception
2. The program halts immediately
3. The method throws the exception to its caller
4. This is not legal, so the program will not compile
The concept of multiple inheritance is implemented in Java by
i. extending two or more classes
ii. extending one class and implementing one or more interfaces
iii. implementing two or more interfaces
iv. all of these
Answer
Answer
(i), (ii), (iii) & (iv)
(i) only
(i) & (iii) only
a--(ii) & (iii) only
Which of the following statements about the try{} block in Java is false?
Answer
Some of the statements in a try{} block will never throw an exception.
The try{} block must appear before the catch{} blocks.
The try{} block cannot contain loops or branches.
The statements in a try{} block may throw several types of exception.
Q
Which of the methods should be implemented if any class implements the
Runnable interface?
1. start()
2. run()
3. wait()
4. notify() and notifyAll()
Q
The concept of multiple inheritance is implemented in Java by
(A) extending two or more classes
(B) extending one class and implementing one or more interfaces
(C) implementing two or more interfaces
(D) all of these
1. (A)
2. (A) & (C)
3. (D)
4. (B) & (C)
(B) & (C)
What is an Applet?
Answer
1. An interactive website
2. A type of computer
3. A graphical user interface
4. A Java program that is run through a web browser
Q
Which is true about an anonymous inner class?
1. It can extend exactly one class and implement exactly one interface.
2. It can extend exactly one class and can implement multiple interfaces.
3. It can extend exactly one class or implement exactly one interface.
4. It can implement multiple interfaces regardless of whether it also
extends a class.
Q
Which statement is true about a static nested class?
1. You must have a reference to an instance of the enclosing class in
order to instantiate it.
2. It does not have access to nonstatic members of the enclosing class.
3. It's variables and methods must be static.
4. It must extend the enclosing class.
q
Which constructs an anonymous inner class instance?
1. Runnable r = new Runnable() { };
2. Runnable r = new Runnable(public void run() { });
3. Runnable r = new Runnable { public void run(){}};
4. [Link](new Runnable() {public void run() { }});
q
When does Exceptions in Java arises in code sequence?
1. Run Time
2. Compilation Time
3. Can Occur Any Time
4. None of the mentioned
Which of these keywords is used to manually throw an exception?
1. try
2. finally
3. throw
4. catch
q
What is the value of "d" after this line of code has been executed?
double d = [Link] ( 2.5 + [Link]() );
1. 2
2. 3
3. 4
4. 2.5
2
q
Which of the following would compile without error?
1. int a = [Link](-5);
2. int b = [Link](5.0);
3. int c = [Link](5.5F);
4. int d = [Link](5L);
q
Which of these class is superclass of String and StringBuffer class?
1. [Link]
2. [Link]
3. ArrayList
4. None of the mentioned
q
Which of these method of class String is used to obtain length of String
object?
1. get()
2. Sizeof()
3. lengthof()
4. length()
q
Which collection class allows you to grow or shrink its size and provides
indexed access to its elements, but whose methods are not synchronized?
1. [Link]
2. [Link]
3. [Link]
4. [Link]
q
Which class does not override the equals() and hashCode() methods,
inheriting them directly from class Object?
1. [Link]
2. [Link]
3. [Link]
4. [Link]
q
What is synchronization in reference to a thread?
1. It’s a process of handling situations when two or more threads need
access to a shared resource.
2. Its a process by which many thread are able to access same shared
resource simultaneously.
3. Its a process by which a method is able to access many different
threads simultaneously.
4. Its a method that allow to many threads to access any information
require.
q
Which of these method waits for the thread to treminate?
1. sleep()
2. isAlive()
3. join()
4. stop()
q
In java, gc() method is available in which package
1. [Link] package
2. [Link] package
3. [Link] package
4. [Link] package
q
Which of these Exceptions is thrown by remote method?
1. RemoteException
2. InputOutputException
3. RemoteAccessException
4. RemoteInputOutputException
Which of these method of DatagramPacket is used to obtain the byte array
of data contained in a datagram?
1. getData()
2. getBytes()
3. getArray()
4. recieveBytes()
Q
Which of these is a return type of getAddress method of DatagramPacket
class?
1. DatagramPacket
2. DatagramSocket
3. InetAddress
4. ServerSocket
3
Q
Which of these methods is used to obtain value of invoking object as a
long?
A: long value()
B: long longValue()
C: Long longvalue()
D: Long Longvalue()
q
Which is true about a method-local inner class?
A: It must be marked final.
B: It can be marked abstract.
C: It can be marked public.
D: It can be marked static.
q
Which of these events is generated when a button is pressed?
A: ActionEvent
B: KeyEvent
C: WindowEvent
D: AdjustmentEvent
Which of these methods can be used to obtain the command name for
invoking ActionEvent object?
1. getCommand()
2. getActionCommand()
3. getActionEvent()
4. getActionEventCommand()
q
Which of these methods can be used to output a sting in an applet?
A: display()
B: print()
C: drawString()
D: transient()
q
Which of these stream contains the classes which can work on character
stream?
A: InputStream
B: OutputStream
C: Character Stream
D: All of the mentioned
q
Which of these method of FileReader class is used to read characters from
a file?
A: read()
B: scanf()
C: get()
D: getInteger()
q
Why we use array as a parameter of main method
A: it is syntax
B: Can store multiple values
C: Both of above
D: None of above
q
Which methods are utilized to control the access to an object in multi
threaded programming
A: Asynchronized methods
B: Synchronized methods
C: Serialized methods
D: None of above
q
Converting a primitive type data into its corresponding wrapper class
object instance is called
A: boxing
B: wrapping
C: instantiation
D: autoboxing
q
Object which can store group of other objects is called
A: Collection object
B: Java object
C: Package
D: Wrapper
added 13 27