Java
Java
Java
1) Which of the following option leads to the portability and security of Java?
a) Bytecode is executed by JVM
b) The applet makes the Java code secure and portable
c) Use of exception handling
d) Dynamic binding between objects
3) What should be the execution order, if a class has a method, static block, instance
block, and constructor, as shown below?
{
System.out.println(" Instance Block");
}
a) 10, 5, 0, 20, 0
b) 10, 30, 20
c) 60, 5, 0, 20
d) 60, 30, 0, 20, 0
11) Evaluate the following Java expression, if x=3, y=5, and z=10:
++z + y - y + z + x++
a) 24
b) 23
c) 20
d) 25
a) 15 times ***
b) 15 times +++++
c) 8 times *** and 7 times +++++
d) Both will print only once
13) Which of the following tool is used to generate API documentation in HTML format
from doc comments in source code?
a) javap tool
b) javaw command
c) Javadoc tool
d) javah command
14) Which of the following creates a List of 3 visible items and multiple selections
abled?
a) new List(false, 3)
b) new List(3, true)
c) new List(true, 3)
d) new List(3, false)
16) Which method of the Class.class is used to determine the name of a class
represented by the class object as a String?
Advertisement
a) getClass()
b) intern()
c) getName()
d) toString()
17) In which process, a local variable has the same name as one of the instance
variables?
a) Serialization
b) Variable Shadowing
c) Abstraction
d) Multi-threading
18) Which of the following is true about the anonymous inner class?
a) It has only methods
b) Objects can't be created
c) It has a fixed class name
d) It has no class name
24) Which of these classes are the direct subclasses of the Throwable class?
a) RuntimeException and Error class
b) Exception and VirtualMachineError class
c) Error and Exception class
d) IOException and VirtualMachineError class
26) In which memory a String is stored, when we create a string using new operator?
a) Stack
b) String memory
c) Heap memory
d) Random storage space
27) What is the use of the intern() method?
a) It returns the existing string from memory
b) It creates a new string in the database
c) It modifies the existing string in the database
d) None of the above
a) Complete
b) Iomplede
c) Cimpletd
d) Coipletd
33) Which of the following is false?
a) The rt.jar stands for the runtime jar
b) It is an optional jar file
c) It contains all the compiled class files
d) All the classes available in rt.jar is known to the JVM
36) Given that Student is a class, how many reference variables and objects are created
by the following code?
a) 5
b) 10
c) 0
d) 100
39) Which of the following is a mutable class in java?
Advertisement
a) java.lang.String
b) java.lang.Byte
c) java.lang.Short
d) java.lang.StringBuilder
41) What is meant by the classes and objects that dependents on each other?
a) Tight Coupling
b) Cohesion
c) Loose Coupling
d) None of the above
42) Given,
43) Which of the following code segment would execute the stored procedure
"getPassword()" located in a database server?
a) CallableStatement cs = connection.prepareCall("{call.getPassword()}");
cs.executeQuery();
b) CallabledStatement callable = conn.prepareCall("{call getPassword()}");
callable.executeUpdate();
c) CallableStatement cab = con.prepareCall("{call getPassword()}");
cab.executeQuery();
d) Callablestatement cstate = connect.prepareCall("{call getpassword()}");
cstate.executeQuery();
44) How many threads can be executed at a time?
a) Only one thread
b) Multiple threads
c) Only main (main() method) thread
d) Two threads
45) If three threads trying to share a single object at the same time, which condition will
arise in this scenario?
a) Time-Lapse
b) Critical situation
c) Race condition
d) Recursion
47) Which of the following modifiers can be used for a variable so that it can be
accessed by any thread or a part of a program?
a) global
b) transient
c) volatile
d) default