Академический Документы
Профессиональный Документы
Культура Документы
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?
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?
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?
11) Which method in thread class causes the currently executing thread object to temporarily pause and
threads to execute?
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
15) A class is declared inside a class but outside a method it is known as ________.
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. 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
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
a. Browser
b. Applet
c. Package
d. None of the above
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
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
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
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) 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) 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
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?
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
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