1 . Please select signed integrals
- char, byte, and short
- byte, short, int, and long
- char, short, and long
2 . Java characters are …
- ASCII code
- Binary code
- Unicode
- ANSI code
3 . Please select the size of an int type
- 32 bytes
- 16 bits
- 32 bits
- 16 bytes
4 . Select default value of boolean type
- true
- false
- 0
- 1
5 . Consider the following line of code:
<br />char x[]=new char[10];<br />After execution, what is value of x[0]?
- 0
- ‘\u0000’
- null
6 . A package statement MUST exist in all classes
- True
- False
7 . Please choose invalid identifiers
- temp
- BIGint
- 25_length
- !length
8 . Please select floating point types
- byte
- int
- double
- short
- long
- float
9 . All operands are evaluated left to right
- true
- false
10 . Consider the following line of code:
<br />byte x=64;<br />byte y=5;<br />byte z= (byte)(x*y);<br />After execution what is value of z?
- 320
- 0
- 645
- 64
11 . Consider the following line of code:
<br />int x=7;<br />int y=4;<br />int z=7/4;<br />After execution what is value of z?
- 1.75
- 0
- 1
- 2
12 . Please select the true statement for ! operator
- The ! operator inverts the value of a boolean expression
- The ! operator inverts the bit pattern of an integral expression.
- Both A and B
- None of the above
13 . Please select arithmetic operations which can result in AirthmeticException
- Multiplication: *
- Division: /
- Modulo: %
- Addition: +
- Subtraction: –
14 . Please select operators which perform bit shifts of the binary representation of the integral types
- <<
- >>
- >>>
- ~
- &
- ^
- |
15 . A protected method may be overridden by …
- A private method
- A protected method
- A public method
- All of the above
16 . A public method may not be overridden by …
- A private method
- A protected method
- A public method
- All of the above
17 . The private modifier can be applied to …
- A variable
- A method
- A top level class
- All of the above
18 . The abstract modifier can NOT be applied to …
- A variable
- A method
- A class
- A constructor
19 . A class variable is declared using following modifiers
- protected
- private
- public
- static
20 . An unary operator operates on a single value
- True
- False
21 . The following types of loop are guaranteed to be executed at least once
- The do loop
- The while loop
- The for loop
- All of the above
22 . The switch() construct is used to make a choice based upon …
- A char value
- An int value
- A String value
- None of the above
23 . The circumstances that can prevent execution of the code in a finally block are
- The death of the thread
- The use of System.exit()
- It is always guaranteed to be executed.
24 . Select correct statement(s)
- The continue statement abandons the loop altogether
- The break statement causes the current iteration of the loop to be abandoned.
- The break statement abandons the loop altogether
25 . How can you declare a overloaded method?
- Reusing the method name with different arguments and same return type
- Reusing the method name with different arguments and different return type
- Reusing the name with identical arguments and return type
- None of the above
26 . How can you declare a overriding method?
- Using the same method name with identical arguments and return type
- Using the same method name with identical arguments and different return type
- Using the same method name with different arguments and same return type
- All of the above
27 . When a default constructor is provided by the compiler?
- If you define no constructor at all in a class
- When you define at least one constructor
- It is always provided whether you define a constructor or not
- It is never provided
28 . A static inner class can access …
- instance variables of the enclosing class
- static variables of the enclosing class
- Both A and B
- None of the above
29 . An inner class created inside a method can access
- Any local variables of a method that contain an inner class.
- Any instance variables of the enclosing class
- Any final variables of the enclosing class or a method that contain an inner class.
- None of the above
30 . Please select true statement(s) for an anonymous inner class
- An anonymous class can not extend to a superclass
- An anonymous class can not implement an interface
- An anonymous class can extend to a supperclass and implement an interface both.
- An anonymous class can extend to a supperclass or implement an interface
31 . Please select true statement(s) for a member inner class
- An inner class in class scope can have any accessibility of the top level class, including private.
- An Inner class defined local to a block may be static
- An anonymous inner class can not declare a constructor.
- An inner class can not have same name as enclosing class.
- All of the above
32 . Please select invalid statement(s) for a thread
- You can restart a dead thread
- You can’t call the methods of a dead thread
- Both of the above
- None of the above
33 . Select correct statements for a java.lang.String
- Strings are sequences of 16 bit Unicode characters.
- Strings are immutable.
- Both of the above
- None of the above
34 . Select correct statements for == operator.
- It compare object reference of two objects
- It compare the value of two objects
- Both of the above
- None of the above
35 . Please select collection(s) that do not reject duplicates
- java.util.List
- java.util.Set
- java.util.Map
- All of the above
36 . Please select a default layout manager of the java.awt.Panel
- java.awt.FlowLayout with left justified
- java.awt.FlowLayout with center justified
- java.awt.FlowLayout with right justified
- None of the above
37 . Please select a default layout manager for the java.awt.Frame
- java.awt.FlowLayout
- java.awt.BorderLayout
- java.awt.GridBagLayout
- None of the above
38 . Please select true statement for prefix operator(++x/–x).
- The prefix operator(++x/–x) evaluates the value of the operand after increment/decrement operation.
- The prefix operator(++x/–x) evaluates the value of the operand before increment/decrement operation.
- Both A and B
- None of the above
39 . Please select true statement(s) for shift operators.
- >>> operator always produces a positive number.
- >> always produces a positive number for a positive number.
- >> always produces a negative number for a negative number.
- None of the above
40 . Please select true statement(s) for shift operators.
- Shifting is not allowed in long integral type
- Shifting is not allowed in float integral type
- Shifting is not allowed in double integral type
- Shifting is not allowed in int integral type.
41 . Please identify correct assignment for boolean type.
- boolean javaExam=true;
- boolean javaExam=True;
- boolean javaExam=1;
- All of the above
42 . Bitwise operator can be applied to …
- Integral types
- Float types
- Both of the above
- None of the above
43 . instanceof operator can be used with …
- interfaces
- Arrays
- Classes
- All of the above
44 . Please select true statement(s)
- The equals method compares content of two objects
- The == operator tests reference of two objects
- The equals method compares reference of two objects.
- The == operator compares content of two objects
45 . Please identify invalid use of comparison operator for the following code:
<br />String s=new String("S");<br />String t=new String("T");<br />int x=83;<br />int y=84;<br />Choose the one below:
- s == t
- x!=y
- x==s
- s!=t
46 . Please select true statement(s) for instanceof operator:
- The instanceof operator can be applied to object reference
- The instanceof operator can be applied to an array.
- Both of the above
- None of the above
47 . please select true statement(s) for static modifier.
- A static method can access non-static variables of the class.
- A static method can call non-static methods.
- A static method can be overridden by non-static method.
- None of the above
48 . Please, select true statement(s) for thread.
- Invoking a constructor of a Thread registers the thread with thread scheduler.
- Calling a start() method of thread registers the thread with thread scheduler.
- Calling a run() method of thread registers the thread with thread scheduler.
- All of the above.
49 . Invoking yield() on a running thread cause following effect(s):
- A running thread will be placed in suspended state.
- A running thread will be placed in sleeping state.
- A running thread will be placed in ready state.
- Neither of the above.
50 . The default priority of the thread is
- 0
- 1
- 5
- 10
51 . Which of the following methods are NOT static of Thread class?
- start()
- sleep(long l)
- run()
- yield()
52 . Select true statement(s) about an inner class declared inside a method, also known as local inner class
- The local inner class can access any local variables declared in the method and the parameters passed to the method.
- The local inner class can access only public variables declared in enclosing class
- The local inner class can access public, private, and protected variables declared in enclosing class.
- The local inner class can access only final declared variables in the method.
53 . How can you prevent class JavaExam from being extended?
- declare class static JavaExam
- declare class synchronized JavaExam
- declare class final JavaExam
- None of the above
54 . Assume that following methods are declared in one class.
1. public void addElement(Object javaExam)
2. public void addElement( Object [] javaExam)
3. public Object addElement ( int index, Object javaExam)
Please select true statement(s) for above methods.
- All methods are example of overloading method
- All methods are example of overriding method
- Method # 1 and method # 2 are example of overloading method, whereas method # 3 is an example of overriding method.
- None of the above
55 . When can’t you override a method?
- when method is declared abstract
- When method is declared final
- when method is declared private
- when method is declared static
56 . Please select invalid declaration of the top level class
- public abstract final class JavaExam
- public final class JavaExam implement Runnable
- protected static class JavaExam
- public class JavaExam extend Thread
57 . Please select invalid types for a switch construct
- float
- long
- String
- All of the above
58 . Please select invalid java keywords
- include
- ifdef
- sizeof
- goto
59 . Which of the following statements are NOT true about Java garbage collection Thread?
- The garbage collection thread has a low priority
- The garbage collection thread can be invoked at any time
- A call to System.gc() is guaranteed to invoke garbage collection thread immediately
- A call to Runtime.getRuntime().gc() is guaranteed to invoke garbage collection thread immediately
60 . An inner class can not declare______ variables.
- static
- protected
- final
- transient
61 . Which of the following types can be added to java.util.Vector?
- reference
- null
- int
- All of the above
62 . Please select a true statement about delete() method of java.io.File.
- It can delete a file
- It can delete an empty directory
- Both of the above
- Neither of the above
63 . The continue statement causes the current iteration of the loop to be skipped and the next iteration starts.
- True
- False
64 . The return type of constructor is void.
- True
- False
65 . ‘null’ is valid java type.
- True
- False
66 . Invoking a constructor of java.io.File class creates a file on the file system.
- True
- False
67 . Select true statement(s) about native modifier.
- native modifier can be applied to a class
- native modifier can be applied to a method
- native modifier can be applied to an instance variable
- native variable can be applied to a class variable
68 . What method(s) needed to be declared by a class implementing Runnable interface?
- public void start()
- public void run()
- public boolean start()
- public boolean run()
69 . The priority of a newly created thread is always Thread.NORM_PRIORITY.
- True
- False
70 . What methods are declared in java.lang.Thread class?
- public static void sleep(long millis, int nanos)
- public static native void sleep(long millis, int nanos)
- public static native void sleep(long millis)
- public static void sleep(long millis)
71 . A yield method of the Thread class suspends the operation of the current thread.
- True
- False
72 . What methods are NOT synchronized in java.util.Vector class?
- size()
- add(int index, Object element)
- capacity()
- get(int index)
73 . Please select unchecked exception(s)?
- java.lang.NullPointerException
- java.lang.ClassNotFoundException
- java.lang.ClassCastException
- java.awt.AWTException
74 . Which of the following declarations are valid to throw an exception?
- throw new java.lang.Exception();
- throws new java.lang.Exception();
- Both of the above
- None of the above
75 . Which of the following classes are immutable?
- java.lang.String
- java.lang.StringBuffer
- java.util.Vector
- java.lang.Integer
76 . Which of the following classes store and retrieve values based on a key?
- java.util.Hashtable
- java.util.Vector
- java.util.LinkedList
- java.util.HashMap
77 . Which of the following classes can store null value for a key?
- java.util.Hashtable
- java.util.HashMap
- java.util.Properties
- All of the above
78 . java.util.Vector uses synchronized methods to store and retrieve values.
- True
- False
79 . java.util.Hashtable uses synchronized methods to store and retrieve values.
- True
- False
80 . java.util.HashMap uses synchronized methods to store and retrieve values.
- True
- False
81 . Which of the following collections maintain object references in the order they were added?
- java.util.Vector
- java.util.Hashtable
- java.util.HashMap
- java.util.ArrayList
82 . java.util.hashtable implements which of the following interfaces?
- java.util.Dictionary
- java.util.Map
- java.util.HashMap
- java.util.Hashmap
Answers
1 : 2 is correct.
2 : 3 is correct.
3 : 3 is correct.
4 : 2 is correct.
5 : 2 is correct.
6 : 2 is correct.
7 : 3 & 4 is correct.
8 : 3 & 6 is correct.
9 : 1 is correct.
10 : 4 is correct. A byte value can represent a range of -128 to +127. Arithmetically answer is 320, but when you store this result to a byte variable you will get a value 64 since result is out of the range (-128 to +127).
11 : 3 is correct.
12 : 1 is correct.
13 : 2 & 3 is correct.
14 : 1,2 & 3 is correct.
15 : 2 & 3 is correct.
16 : 1 & 2 is correct.
17 : 1 & 2 is correct.
18 : 1 & 4 is correct.
19 : 4 is correct.
20 : 1 is correct. + and – operator can take two values.
21 : 1 is correct.
22 : 1 & 2 is correct.
23 : 1 & 2 is correct.
24 : 3 is correct.
25 : 1 & 2 is correct.
26 : 1 is correct.
27 : 1 is correct.
28 : 2 is correct.
29 : 3 is correct.
30 : 4 is correct.
31 : 1,3 & 4 is correct.
32 : 3 is correct.
33 : 3 is correct.
34 : 1 is correct.
35 : 1 is correct.
36 : 2 is correct.
37 : 2 is correct.
38 : 1 is correct.
39 : 2 & 3 is correct.
40 : 2 & 3 is correct.
41 : 1 is correct.
42 : 1 is correct.
43 : 4 is correct.
44 : 1 & 2 is correct.
45 : 3 is correct.
46 : 3 is correct.
47 : 4 is correct.
48 : 2 is correct.
49 : 3 is correct.
50 : 3 is correct.
51 : 1 & 3 is correct.
52 : 3 & 4 is correct.
53 : 3 is correct.
54 : 1 is correct.
55 : 2 is correct.
56 : 1,2,3 & 4 is correct.
57 : 4 is correct.
58 : 1,2 & 3 is correct.
59 : 2,3 & 4 is correct.
60 : 1 is correct.
61 : 1 & 2 is correct.
62 : 3 is correct.
63 : 1 is correct.
64 : 2 is correct.
65 : 1 is correct.
66 : 2 is correct.
67 : 2 is correct.
68 : 2 is correct.
69 : 2 is correct. A newly created thread inherits the priority of the Thread that creates it.
70 : 1 & 3 is correct.
71 : 1 is correct.
72 : 1,2 & 3 is correct.
73 : 1 & 3 is correct.
74 : 1 is correct.
75 : 1 & 4 is correct.
76 : 1 & 4 is correct.
77 : 2 is correct.
78 : 1 is correct.
79 : 1 is correct.
80 : 2 is correct.
81 : 1 & 4 is correct.
82 : 2 is correct.