Вы находитесь на странице: 1из 11

1

1) java.applet defines how many interfaces?

a. 2
b. 3
c. 4
d. 5
Answer Explanation
ANSWER: 3
2) The wrapper classes are part of the which package, that is imported by default into all Java programs?
a. java.lang
b. java.awt
c. java.io
d. java.util
Answer Explanation
ANSWER: java.lang
3) Which provides a new way for your programs to interface with code libraries written in
other languages?

a. JNI
b. JDBC
c. RMI
d. GUI

ANSWER: JNI

4 Which method is used in thread class to test if the current thread has been interrupted?
a. public static boolean interrupted()
b. public boolean isInterrupted()
c. public void interrupt()
d. public boolean isAlive()
Answer a

5- Which of the following ways specify/ies to load the class files in temporary?

a. By setting the classpath in the command prompt


b. By classpath switch
c. Both A & B
d. None of the above

ANSWER: Both A & B

6- Which allows you to migrate your implementations over time without breaking the code that depends on the pu
your classes?
a. Polymorphism
b. Inheritance
c. Encapsulation
d. Both A & B

ANSWER: Encapsulation
7- Which allows you to define one interface and have multiple implementations?
a. Encapsulation
b. Inheritance
c. Polymorphism
d. None of the above
ANSWER: Polymorphism
2

8 Which type of java package that contains wide range of classes and methods are used for performing d
functionalities?

a. User Defined Package


b. Java System Packages
c. User System Packages
d. None of the above
Answer Explanation
ANSWER: Java System Packages

9) Which concept is used to make Java more memory efficient (because no new objects
are created if it exists already in string constant pool)?

a. String literal
b. By new keyword
c. Both A & B
d. None of the above
Answer Explanation
ANSWER: String literal
10) Which are also known as inner classes?

a. Non-static nested class


b. Static nested class
c. Nested class
d. None of the above

11) Which method in thread class causes the currently executing thread object to temporarily pause and
threads to execute?

a. public boolean isAlive()


b. public int getId()
c. public void yield()
d. public boolean isDaemon()
ANSWER: public void yield()
12) What are the main subclasses of the Exception class?

a. IOException class
b. RuntimeException Class
c. ClassCastException
d. Both A & B
ANSWER: Both A & B

13) Which method is used to invoke the garbage collector to perform the cleanup
processing?

a. gc() method
b. finalize() method
c. q.get() method
d. None of the above
3

ANSWER: gc() method

14) What is the advantage of Method Overloading?

a. Method overloading increases the readability of the program


b. Method overloading does not increases the readability of the program
c. Method overloading does not increases the reliability of the program
d. None of the above

ANSWER: Method overloading increases the readability of the program

15) A class is declared inside a class but outside a method it is known as ________.

a. Anonymous Inner class


b. Member Inner class
c. Local Inner class
d. Static nested class
ans-b

16) Which package includes StringTokenizer that tokenizes a string into independent words?

a. java.awt
b. java.applet
c. java.util
d. java.lang

ANSWER: java.util

17) What will happen if we call the run() method directly instead of calling the start() method?

a. Each thread starts in a separate call stack.


b. Invoking the run() method from main thread, the run() method goes onto the current call stack rather th
beginning of a new call stack.
c. Both A & B
d. None of the above

ANSWER: Both A & B


18) How many types of constructor are defined in the StringTokenizer class?

a. 2
b. 3
c. 4
d. 5

ANSWER: 3

19) Which class is used when a program does not want to handle an exception?

a. Throws
b. Try
4

c. Catch
d. Final

ANSWER: Throws

20) What type of constructor is used to provide different values to the distinct objects?

a. Default constructor
b. Parameterized constructor
c. Overloading constructor
d. None of the above

ANSWER: Parameterized constructor

21) Which method of DataInputStream class reads a line from the file and returns it as a string?

a. WriteInt()
b. readLine()
c. readInt()
d. writeDouble()

ANSWER: readLine()
22) Which state is the thread still alive, but is currently not eligible to run?

a. Non-Runnable
b. Terminated
c. Runnable
d. Running

ANSWER: Non-Runnable
23) Under which package is the string class encapsulated?

a. java.lang
b. java.util
c. java.io
d. java.awt

ANSWER: java.lang

24) How many methods does a thread class provides for sleeping a thread?

a. 3
b. 1
c. 4
d. 2

ANSWER: 2
25) Which method of object class can clone an object?
5

a. copy()
b. Objectcopy()
c. Objectclone()
d. Clone()

ANSWER: Objectclone()
26) Which is a technique in Java in which a class can have any number of constructors that differ in par

a. Constructor overloading
b. Method overloading
c. Operator overloading
d. None of the above

ANSWER: Constructor overloading


27) What can be accessed or inherited without actual copy of code to each program?

a. Browser
b. Applet
c. Package
d. None of the above

28) Which provides accessibility to classes and interface?

a. import
b. Static import
c. All the above
d. None of the above

ANSWER: import
29) Which Thread pool is used where container creates a thread pool to process the
request?

a. Servlet
b. JSp
c. All of the above
d. None of the above

ANSWER: All of the above


30) Which method of string class in java is used to convert the boolean into String?

a. public static String valueOf(double I)


b. public static String valueOf(boolean I)
c. public boolean equals(Object anObject)
d. public static String valueOf(Object obj)

ANSWER: public static String valueOf(double I)


6

31) What is known as the classes that extend Throwable class except RuntimeException and Error?

a. Checked Exception
b. Unchecked Exception
c. Error
d. None of the above

ANSWER: Checked Exception


32) Which is irrecoverable?

a. Error
b. Checked Exception
c. Unchecked Exception
d. Both B & C

ANSWER: Error
33) Mutual exclusive and inter-thread communication are which type of Synchorization?

a. Thread Synchronization
b. Process Synchronization
c. Object Synchronization
d. None of the above

ANSWER: Thread Synchronization


34) Which method is used to change the name of a thread?

a. public String getName()


b. public void setName(String name)
c. public void getName()
d. public String setName(String name)

ANSWER: public void setName(String name)

35) Which mechanism is used when a thread is paused running in its critical section and another thread
(or lock) in the same critical section to be executed?

a. Inter-thread communication
b. Initial-thread communication
c. Mutual Exclusive
d. None of the above
ANSWER: Inter-thread communication

36) In Naming a thread which method is used to change the name of a thread?
A) public String getName()
B) public void setName(String name).
C) public void getName()
D) public String setName(String name)
ANSWER: B) public void setName(String name)
37) In which mechanism a thread is paused running in its critical section and another thread is allowed to
the same critical section to be executed?
7

A) Inter-thread communication
B) Initial-thread communication
C) Mutual Exclusive
D) None of the above
ANSWER: A) Inter-thread communication

38) How many ways are there to access package from another package?

A) 3
B) 2
C) 1
D) 5

ANSWER: A) 3
39) A package is a collection of related Java entities such as ?

A) classes,interfaces,exceptions
B) errors and enums
C) Both A & B
D) None of the above
ANSWER: C) Both A & B

40)In object class parent class reference variable can refer the child class object, known as?

A) Upcasting
B) Implicit casting
C) Explicit casting
D) Boolean casting

ANSWER: A) Upcasting
41) Which method compares the given object to this object?

A) public boolean equals(Object obj)


B) public final void notifyAll()
C) public final void notify()
D) public final ClassgetClass()
ANSWER: A) public boolean equals(Object obj)
42) The clone() method is defined in?
A) Abstract class
B) Object Class
C) ArrayList class
D) None of the above
ANSWER: B) Object Class
43) Which method of object class can clone an object?

A) copy()
B) Objectcopy()
C) Objectclone()
D) Clone()
8

ANSWER: C) Objectclone()
44) Java defines a peer class of String, called?

A) StringBuffer
B) StringBuilder
C) Both A & B
D) None of the above
ANSWER: A) StringBuffer
45) Which concept is used to make Java more memory efficient (because no new objects are created if i
string constant pool)?

A) String literal
B) By new keyword
C) Both A & B
D) None of the above
ANSWER: A) String literal
46) Which method of string class in java Returns a new string that is a substring of this string?

A) public String substring(int beginIndex,int endIndex)


B) public String substring(int beginIndex)
C) public boolean equalsIgnoreCase(String another)
D) Both A & B
ANSWER: D) Both A & B
47) These commonly used methods of

1) public abstract int read()throws IOException


2) public int available()throws IOException
3) public void close()throws IOException

A) OutputStream class
B) InputStream class
C) Input/OutputStream class
D) None of the above
ANSWER: B) InputStream class
48) SequenceInputStream class is used to read data from?
A) Single Stream
B) Multiple streams
C) Multilevel Streams
D) None of the above
ANSWER: B) Multiple streams

49) Which are the ways to read data from the keyboard?
A) InputStreamReader
B) Console
C) Scanner
D) DataInputStream
E) All Mentioned above
ANSWER: E) All Mentioned above
9

50) Which class breaks the input into tokens using a delimiter which is whitespace bydefault,
It provides many methods to read and parse various primitive values?

A) Console class
B) Scanner class
C) Both A & B
D) None of the above
ANSWER: B) Scanner class
51) Which class automatically flushes the data so there is no need to call flush() method.
Moreover, its methods don't throw IOException?

A) Console class
B) Scanner Class
C) FileInputStream class
D) PrintStream class
ANSWER: D) PrintStream class

52) Which method compares the given object to 'this' object?


a. public boolean equals(Object obj)
b. public final void notifyAll()
c. public final void notify()
d. public final ClassgetClass()
ANSWER: public boolean equals(Object obj)
53) Which is commonly used method of ByteArrayOutputStream class?

a. ByteArrayOutputStream()
b. ByteArrayOutputStream(int size)
c. public synchronized void writeTo(OutputStream out) throws IOException
d. Both A & B
Answer Explanation
ANSWER: public synchronized void writeTo(OutputStream out) throws IOException
54) Which methods are provided by the PrintStream class?

a. Read data to another stream


b. Write data to another stream
c. Read data to same stream
d. Write data to same stream

ANSWER: Write data to another stream

55) What is used to convert the byte-oriented stream into character-oriented stream?

a. Console
b. Scanner
c. InputStreamReader
d. DataInputStream

ANSWER: InputStreamReader
10

56) Which is used as an internal buffer and adds more efficiency than to write data directly into a stream
makes the performance fast?

a. BufferedOutputStream
b. ByteArrayOutputStream
c. BufferedInputStream
d. ByteArrayInputStream

ANSWER: BufferedOutputStream!
57) Which class can be used to read data line by line using the readLine() method?

a. BufferedReader
b. InputStreamReader
c. DataInputStream
d. None of the above
ANSWER: BufferedReader

58) Which stream does Java application uses to read data from a source, it may be a file, an array, peri
socket?

A) InputStream
B) OutputStream
C) Input/OutputStream
D) None of the above
ANSWER: A) InputStream

59) From where the SequenceInputStream class is used to read data?

a. Single Stream
b. Multiple streams
c. Multilevel Streams
d. None of the above
ANSWER: Multiple streams

60) Which class can be used to read data line by line by readLine() method?

A) BufferedReader
B) InputStreamReader
C) DataInputStream
D) None of the above
ANSWER: A) BufferedReader
61) Which is used to converts the byte-oriented stream into character-oriented stream?

A) Console
B) Scanner
C) InputStreamReader
D) DataInputStream
ANSWER: C) InputStreamReader

62) Which class automatically flushes the data so that there is no need to call the flush()
method. Moreover, its methods don't throw IOException?
11

a. Console class
b. Scanner Class
c. FileInputStream class
d. PrintStream class

ANSWER: PrintStream class

Вам также может понравиться