-
Please select signed integrals
-
char, byte, and short
-
byte, short, int, and long
-
char, short, and long
-
Java characters are ...
-
ASCII code
-
Binary code
-
Unicode
-
ANSI code
-
Please select the size of an int type
-
32 bytes
-
16 bits
-
32 bits
-
16 bytes
-
Select default value of boolean type
-
true
-
false
-
0
-
1
-
Consider the following line of code:
char x[]=new char[10];
After execution, what is value of x[0]?
-
0
-
'\u0000'
-
null
-
A package statement MUST exist in all classes
-
True
-
False
-
Please choose invalid identifiers
-
temp
-
BIGint
-
25_length
-
!length
8. Please select
floating point types
-
byte
-
int
-
double
-
short
-
long
-
float
-
All operands are evaluated left to right
-
true
-
false
-
Consider the following line of code:
byte x=64;
byte y=5;
byte z= (byte)(x*y);
After execution what is value of z?
-
320
-
0
-
645
-
64
-
Consider the following line of code:
int x=7;
int y=4;
int z=7/4;
After execution what is value of z?
-
1.75
-
0
-
1
-
2
-
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
-
Please select arithmetic operations which can result in
AirthmeticException
-
Multiplication: *
-
Division: /
-
Modulo: %
-
Addition: +
-
Subtraction: -
-
Please select operators which perform bit shifts of the binary
representation of the integral types
-
<<
-
>>
-
>>>
-
~
-
&
-
^
-
|
-
A protected method may be overridden by ...
-
A private method
-
A protected method
-
A public method
-
All of the above
-
A public method may not be overridden by ...
-
A private method
-
A protected method
-
A public method
-
All of the above
-
The private modifier can be applied to ...
-
A variable
-
A method
-
A top level class
-
All of the above
-
The abstract modifier can NOT be applied to ...
-
A variable
-
A method
-
A class
-
A constructor
-
A class variable is declared using following modifiers
-
protected
-
private
-
public
-
static
-
An unary operator operates on a single value
-
True
-
False
-
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
-
The switch() construct is used to make a choice based upon ...
-
A char value
-
An int value
-
A String value
-
None of the above
-
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.
-
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
-
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
-
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
-
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
-
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
-
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
-
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
-
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
-
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
-
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
-
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
-
Please select collection(s) that do not reject duplicates
-
java.util.List
-
java.util.Set
-
java.util.Map
-
All of the above
-
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
-
Please select a default layout manager for the java.awt.Frame
-
java.awt.FlowLayout
-
java.awt.BorderLayout
-
java.awt.GridBagLayout
-
None of the above
-
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
-
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
-
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.
-
Please identify correct assignment for boolean type.
-
boolean javaExam=true;
-
boolean javaExam=True;
-
boolean javaExam=1;
-
All of the above
-
Bitwise operator can be applied to ...
-
Integral types
-
Float types
-
Both of the above
-
None of the above
-
instanceof operator can be used with ...
-
interfaces
-
Arrays
-
Classes
-
All of the above
-
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
-
Please identify invalid use of comparison operator for the
following code:
String s=new String("S");
String t=new String("T");
int x=83;
int y=84;
-
s == t
-
x!=y
-
x==s
-
s!=t
-
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
-
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
-
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.
-
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.
-
The default priority of the thread is
-
0
-
1
-
5
-
10
-
Which of the following methods are NOT static of Thread class?
-
start()
-
sleep(long l)
-
run()
-
yield()
-
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.
-
How can you prevent class JavaExam from being extended?
A. declare class static
JavaExam
B. declare class
synchronized JavaExam
C. declare class final
JavaExam
D. None of the above
-
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
A. All methods are example
of overriding method
B. Method # 1 and method #
2 are example of overloading method, whereas method # 3 is an example of
overriding method.
C. None of the above
-
When can't you override a method?
.
when method is declared abstract
A. When method is declared
final
B. when method is declared
private
C. when method is declared
static
-
Please select invalid declaration of the top level class
.
public abstract final class JavaExam
A. public final class
JavaExam implement Runnable
B. protected static class
JavaExam
C. public class JavaExam
extend Thread
-
Please select invalid types for a switch construct
.
float
A. long
B. String
C. All of the above
-
Please select invalid java keywords
.
include
A. ifdef
B. sizeof
C. goto
-
Which of the following statements are NOT true about Java garbage
collection Thread?
.
The garbage collection thread has a low priority
A. The garbage collection
thread can be invoked at any time
B. A call to System.gc()
is guaranteed to invoke garbage collection thread immediately
C. A call to
Runtime.getRuntime().gc() is guaranteed to invoke garbage
collection thread immediately
-
An inner class can not declare______ variables.
.
static
A. protected
B. final
C. transient
-
Which of the following types can be added to java.util.Vector?
.
reference
A. null
B. int
C. All of the above
-
Please select a true statement about delete() method of
java.io.File.
.
It can delete a file
A. It can delete an empty
directory
B. Both of the above
C. Neither of the above
-
The continue statement causes the current iteration
of the loop to be skipped and the next iteration starts.
.
True
A. False
-
The return type of constructor is void.
.
True
A. False
-
'null' is valid java type.
.
True
A. False
-
Invoking a constructor of java.io.File class creates a file on the
file system.
.
True
A. False
-
Select true statement(s) about native modifier.
.
native modifier can be applied to a class
A. native modifier can be
applied to a method
B. native modifier can be
applied to an instance variable
C. native variable can be
applied to a class variable
-
What method(s) needed to be declared by a class
implementing Runnable interface?
.
public void start()
A. public void run()
B. public boolean start()
C. public boolean run()
-
The priority of a newly created thread is always
Thread.NORM_PRIORITY.
.
True
A. False
-
What methods are declared in java.lang.Thread
class?
.
public static void sleep(long millis, int nanos)
A. public static native
void sleep(long millis, int nanos)
B. public static native
void sleep(long millis)
C. public static void
sleep(long millis)
-
A yield method of the Thread class suspends the
operation of the current thread.
.
True
A. False
-
What methods are NOT synchronized in java.util.Vector class?
.
size()
A. add(int index, Object
element)
B. capacity()
C. get(int index)
-
Please select unchecked exception(s)?
.
java.lang.NullPointerException
A.
java.lang.ClassNotFoundException
B.
java.lang.ClassCastException
C. java.awt.AWTException
-
Which of the following declarations are valid to throw an
exception?
.
throw new java.lang.Exception();
A. throws new
java.lang.Exception();
B. Both of the above
C. None of the above
-
Which of the following classes are immutable?
.
java.lang.String
A. java.lang.StringBuffer
B. java.util.Vector
C. java.lang.Integer
-
Which of the following classes store and retrieve values based on a
key?
.
java.util.Hashtable
A. java.util.Vector
B. java.util.LinkedList
C. java.util.HashMap
-
Which of the following classes can store null value for a key?
.
java.util.Hashtable
A. java.util.HashMap
B. java.util.Properties
C. All of the above
-
java.util.Vector uses synchronized methods to store and retrieve
values.
.
True
A. False
-
java.util.Hashtable uses synchronized methods to store and retrieve
values.
.
True
A. False
-
java.util.HashMap uses synchronized methods to store and retrieve
values.
.
True
A. False
-
Which of the following collections maintain object references in
the order they were added?
.
java.util.Vector
A. java.util.Hashtable
B. java.util.HashMap
C. java.util.ArrayList
-
java.util.hashtable implements which of the following
interfaces?
.
java.util.Dictionary
A. java.util.Map
B. java.util.HashMap
C. java.util.Hashmap
Answers:
-
B
-
C
-
C
-
B
-
B
-
B
-
C and D
-
C and F
-
A
-
D. Comment: 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).
-
C
-
A
-
B and C are correct
-
A, B, and C
-
B and C
-
A and B
-
A and B
-
A and D
-
D
-
A. Comment: + and - operator can take two values
-
A
-
A and B
-
A and B
-
C
-
A and B
-
A
-
A
-
B
-
C
-
D
-
A , C, and D
-
C. Thanks Chris Pereira for your feedback in our discussion
area.
-
C
-
A
-
A
-
B
-
B
-
A
-
B, and C.
-
B and C
-
A
-
A
-
D
-
A and B
-
C
-
C
-
D
-
B
-
C
-
C
-
A and C
-
C and D
-
C
-
A
-
B
-
A, B, C, and D
-
D
-
A, B, and C
-
B, C, and D
-
A
-
A and B
-
C
-
A
-
B
-
A
-
B
-
B
-
B
-
B Comment: A newly created thread inherits the
priority of the Thread that creates it.
-
A and C
-
A
-
A, B, and C
-
A and C
-
A
-
A and D
-
A and D
-
B
-
A
-
A
-
B
-
A and D
-
B
|