1. Which of these is known
as short-circuit and operator?
a) &&, b)
&, c) ? &, d) None of these.
2. A constructor can be
inherited using the keyword?
3.
int i = 2;
System.out.println(“welcome”+1+2);
The output is :
a) welcome3 b) welcome12
c) compiler error d) none
of these.
4. To inherit an interface
from a class we use the keyword
a) extends, b) implements
,c) both (a) & (b), d) none of these.
5. In java applet, ‘Stop (
)’ method can be invoked for a
thread
a) once, b) twice, c) compiler error, d) not at
all.
6. Dynamic method
dispatcher is used for
a) resolving method overriding
b) resolving multilevel inheritance
c) resolving multiple inheritance anomaly
d) none of these.
7. JVM stands for
a) Java Virtual Machine
b) Java Visual Machine
c) Java Vision Machine
d) None of these.
8. Each time we shift a
value to the right using ‘>>’ operator it divides the value by ?
a) 4, b) 2, c) 8,
d) None of these.
9. Which of the following
statement is true regarding constructors?
a) All cases must be define as a constructor
b) A constructor can be defined private
c) A constructor can return a value
d) A constructor must initialize all the fields of a
class.
10.
int x = 2;
for
(x = 0; x < 5; x++)
System.out.println(x);
The
output is
a)
0 1 2 3 4 b) 1 2 3 4
c) 2 3 4 d) none of these.
11. A constructor
a)
Must have the same name as the class it is declared within
b)
is used to create objects
c)
may be declared private
d)
none of these.
e)
a, b, c.
12. Which of the following
may be part of a class definition?
a)
Instance variables b) Instance
methods
c)
Constructors d) All of these.
13. What is the difference
between a Java applet and a Java application?
a)
An application can in general be trusted whereas an applet can't
b)
An applet must be executed in a browser environment
c)
An applet is not able to access the files of the computer it runs on
d)
(a), (b) and (c).
14. What is byte code in the
context of Java?
a)
The type of code generated by a Java compiler
b)
The type of code generated by a Java Virtual Machine
c)
It is another name for a Java source file
d)
It is the code written within the instance methods of a class.
15. What is garbage
collection in the context of Java?
a)
The operating system periodically deletes all of the java files available on
the system
b)
Any package imported in a program and not used is automatically deleted
c)
When all references to an object are gone, the memory used by the object
is automatically reclaimed
d) The JVM checks the output of any Java program and deletes anything that doesn't make
sense.
16. Consider the following
code snippet
String
river = new String ("Columbia") ;
System.out.println(river.length())
;
What
is printed ?
a)
6, b) 7, c) 8, d) Columbia,e) River.
17. You read the following
statement in a Java program that compiles and executes
submarine.dive(depth);
What
can you say for sure ?
a)
Depth must be an int
b)
Dive must be a method
c)
Dive must be the name of an instance field
d)
Submarine must be the name of a class
e)
Submarine must be a method.
18. Consider the following
program:
import
myLibrary. ;
public
class ShowSomeClass
{
//
code for the class...
}
What is the name of the Java
file containing this proram ?
a)
myLibrary.java
b)
ShowSomeClass.java
c)
ShowSomeClass
d)
ShowSomeClass.class
e)
Any file name with the java suffix will do.
19. Which of the following
is TRUE?
a)
In java, an instance field declared public generates a compilation error
b)
int is the name of a class available in the package
java.lang
c)
Instance variable names may only contain letters and digits.
d)
A class has always a constructor ( possibly automatically supplied by the
java compiler )
e)
The more comments in a program, the faster the program runs.
20. What is the full form of
JVM ?
a) Java Visual Machine
b) Java Variable Management
c) Java Virtual
Machine
d) None of these.
21. Which is the integer type
among the following ?
a)
Float, b) Byte,c) Chard, d)Double.
22. Which is the wrong
statement in automatic type conversion?
I)
Two types should be compatible
II)
The source type should be smaller than destination
III)
type.
The destination
destinaion type
a) I & II
c) II & III
type should be larger
b) I & III
d) None of these.
than
23. The default
constructors automatically initialize all
Instance variables to
a)
0, b) 1,c) – 1, d) none of these.
24. Which operator is used
to create memory to object ?
a) New, b) Dot, c) both (a) and (b),d) none of
these.
25. When you implement an
interface method, it must be declared as
a) public, b) private, c)
protected, d) none of these.
NB:It must be default access specifiers & it is
not equal to public, but consider as equivalent to public. So ans. May be
public.
26. ......................
wakes up the first thread that called
wait() on the same object.
a) Notify, b) Notifyall,c) both
(a) & (b), d) none of these.
27. ......................... abstract method is the only entry point to the
thread.
a) suspend(), b) run(),
c) resume(), d) wait().
28. ........................
method is called each time your applet's output must be drawn.
a) init(), b) start(),c) paint(),
d) destroy().
29. To extract a single
character from a string, we can refer directly to an individual character via
the
.........................
method.
a) getchars(), b) putchars(),c)
CharAt(), d) all of these.
30. .........................
interface defines one method to
recognize the state of an
item changes.
a) keylistener, b)
item listener,
c)
focus listener d) all of these.
31. JVM stands for
a) Java Virtual Machine b) Java Vision Machine
c) Java Visual Machine d) none of these.
32. String str
="ABCD";
System.out.println
(str.charAt(2));
The output is
a) C, b) 2,c)
exception occurs, d) none of these.
33. Dynamic method
dispatcher is used full for
a) resolving method
overriding
b) resolving multilevel
inheritance
c) resolving multiple
inheritance anomaly
d) none of these.
34. In Java applet, stop( )
method can be invoked
a) once, b)
twice,c) many times, d) not at all.
35. Which of the following
statements is true regarding constructors?
a) All cases must define a
constructor
b) A constructor can be
declared private
c) A constructor can return
a value
d) A constructor must
initialize all the fields of a class.
36. What is the return type
of read( ) method of
InputStream class?
a) String, b)
Float,c) Void, d) None of these.
37. Which of the following
JSP expressions are valid ?
a)
<%="Sorry"+"for the"+"break"%>
b) <%="Sorry"+"for
the"+"break";%>
c)
<%="Sorry"%>
d)
<%="Sorry";%>
38.
What happens if Database
Updation code is written in
ejbPassivate( ) method and
if this method is called ?
a) Exception is thrown
b) Successfully executes the
Database Updation code
c)
Compilation error occurs
indicating that Database
Updation code should not be
written in
ejbPassivate( )
d)
ejbStore(
) method is called.
39. Java bytecode is saved in
files with names that end with
a) .class ,b)
.code ,c) .java, d) .exe
40.
An exception is
a) run-time error
b) machine error
c) compile time error
d) none of these.
41. From the following which one
is not Java primitive data type ?
a) Byte, b) Boolean, c)
Short, d) Variant.
42. The ability to declare
different methods with the same name in a class is known
as
a) Method overloading
b) Method overriding
c) Recursion d)
None of these.
43. Which member function of a class is used to create object
of that class?
a) Constructor,
b) New, c) Object, d) None of these.
44. How many default constructor
one can have in a class ?
a) 1, b) 4,
c)0, d) 2.
45. The many catch clauses can a
try statement have without finally ?
a) One, b) Any number,
c) Zero, d) None of these.
46. Which class cannot be
instantiated ?
a) Abstract, b) Public, c) Final,
d) Protected.
47. All exceptions in Java are
subclass of
a) Throwable, b) Abstract,
c) Error, d) Throw.
48. Data Input is
a) an abstract class
defined in Java.io
b) a class we can use to
read primitive data types
c) an interface that defines
methods to open files