MCQ_JAVA_Answer
MCQ_JAVA_Answer
1) Which of the following option leads to the portability and security of Java?
1. Dynamic
2. Architecture Neutral
3. Use of pointers
4. Object-oriented
3) What should be the execution order, if a class has a method, static block, instance block,
and constructor, as shown below?
1. 10, 5, 0, 20, 0
2. 10, 30, 20
3. 60, 5, 0, 20
4. 60, 30, 0, 20, 0
1. JVM
2. JRE
3. JDK
4. JDB
1. char ch = '\utea';
2. char ca = 'tea';
3. char cr = \u0223;
4. char cc = '\itea';
8) What is the return type of the hashCode() method in the Object class?
1. Object
2. int
3. long
4. void
1. ABH8097
2. L990023
3. 904423
4. 0xnf029L
1. 0
2. Not a Number
3. Infinity
4. Run time exception
11) Evaluate the following Java expression, if x=3, y=5, and z=10:
++z + y - y + z + x++
1. 24
2. 23
3. 20
4. 25
13) Which of the following tool is used to generate API documentation in HTML format from
doc comments in source code?
1. javap tool
2. javaw command
3. Javadoc tool
4. javah command
14) Which of the following creates a List of 3 visible items and multiple selections abled?
1. new List(false, 3)
2. new List(3, true)
3. new List(true, 3)
4. 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?
1. getClass()
2. intern()
3. getName()
4. toString()
17) In which process, a local variable has the same name as one of the instance variables?
1. Serialization
2. Variable Shadowing
3. Abstraction
4. Multi-threading
18) Which of the following is true about the anonymous inner class?
1. java.util package
2. java.lang package
3. java.awt package
4. java.io package
1. Runnable Interface
2. Marker Interface
3. Abstract Interface
4. CharSequence Interface
1. Applet class
2. Window class
3. Frame class
4. Dialog class
24) Which of these classes are the direct subclasses of the Throwable class?
26) In which memory a String is stored, when we create a string using new operator?
1. Stack
2. String memory
3. Heap memory
4. Random storage space
1. Runnable interface
2. Remote interface
3. Readable interface
4. Result interface
1. object
2. strictfp
3. main
4. system
1. package
2. import
3. extends
4. export
1. Complete
2. Iomplede
3. Cimpletd
4. Coipletd
36) Given that Student is a class, how many reference variables and objects are created by
the following code?
1. Map m = hashMap.synchronizeMap();
2. HashMap map =hashMap.synchronizeMap();
3. Map m1 = Collections.synchronizedMap(hashMap);
4. Map m2 = Collection.synchronizeMap(hashMap);
38) Given,
1. 5
2. 10
3. 0
4. 100
1. java.lang.String
2. java.lang.Byte
3. java.lang.Short
4. java.lang.StringBuilder
1. No error
2. Method is not defined properly
3. Constructor is not defined properly
4. Extra parentheses
41) What is meant by the classes and objects that dependents on each other?
1. Tight Coupling
2. Cohesion
3. Loose Coupling
4. None of the above
42) Given,
1. 10
2. 11
3. 15
4. None of the above
43) Which of the following code segment would execute the stored procedure
"getPassword()" located in a database server?
1. CallableStatement cs = connection.prepareCall("{call.getPassword()}");
cs.executeQuery();
2. CallabledStatement callable = conn.prepareCall("{call getPassword()}");
callable.executeUpdate();
3. CallableStatement cab = con.prepareCall("{call getPassword()}");
cab.executeQuery();
4. Callablestatement cstate = connect.prepareCall("{call getpassword()}");
cstate.executeQuery();
45) If three threads trying to share a single object at the same time, which condition will
arise in this scenario?
1. Time-Lapse
2. Critical situation
3. Race condition
4. 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?
1. global
2. transient
3. volatile
4. default
1. UTF-8
2. Default encoding of the host platform
3. UTF-12
4. None of the above