219
95.1k

610+ Java Programming Solved MCQs

These multiple-choice questions (MCQs) are designed to enhance your knowledge and understanding in the following areas: Bachelor of Computer Applications (BCA) , Bachelor of Science in Computer Science (BSc CS) , Master of Computer Applications (MCA) , Programming Languages .

201.

What is multithreaded programming?

A. It’s a process in which two different processes run simultaneously.
B. Its a process in which two or more parts of same process run simultaneously.
C. Its a process in which many different process are able to access same information.
D. Its a process in which a single process can access information from many sources.
Answer» B. Its a process in which two or more parts of same process run simultaneously.
202.

Which of these are types of multitasking?

A. Process based multitasking
B. Thread based multitasking
C. Both a & b
D. None of the mentioned
Answer» D. None of the mentioned
203.

Which of these packages contain all the Java’s built in exceptions?

A. java.io
B. java.util
C. java.lang
D. java.net
Answer» C. java.lang
204.

Thread priority in Java is?

A. Integer
B. Float
C. Double
D. Long
Answer» A. Integer
205.

What will happen if two thread of same priority are called to be processed simultaneously?

A. Any one will be executed first lexographically
B. Both of them will be executed simultaneously
C. None of them will be executed
D. It is dependent on the operating system.
Answer» D. It is dependent on the operating system.
206.

Which of these statements is incorrect?

A. By multithreading CPU’s idle time is minimized, and we can take maximum use of it.
B. By multitasking CPU’s idle time is minimized, and we can take maximum use of it.
C. Two thread in Java can have same priority
D. A thread can exist only in two states, running and blocked.
Answer» D. A thread can exist only in two states, running and blocked.
207.

Which method executes only once

A. start() method
B. init() method
C. stop() method
D. destroy() method
Answer» B. init() method
208.

Thread class is available in

A. java.io package
B. java.lang package
C. java.awt package
D. java.util package
Answer» B. java.lang package
209.

Minimum threads in a program are

A. 1
B. 2
C. 5
D. Many
Answer» A. 1
210.

Interfaces helps in which type of inheritance

A. Multiple inheritance
B. Multilevel inheritance
C. Hierarchical inheritance
D. None of above
Answer» A. Multiple inheritance
211.

Which of these values is returned by read () method is end of file (EOF) is encountered?

A. 0
B. 1
C. -1
D. Null
Answer» C. -1
212.

Which of these exception is thrown by close () and read () methods?

A. IOException
B. FileException
C. FileNotFoundException
D. FileInputOutputException
Answer» A. IOException
213.

Which exception is thrown by the read ( ) method of input stream class?

A. Exception
B. ClassNotFoundException
C. read Exception
D. IOException
Answer» D. IOException
214.

What 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 in automatically deleted.
C. When all references to an object are gone, the memory used by the object is automatically reclaim
Answer» C. When all references to an object are gone, the memory used by the object is automatically reclaim
215.

In order for a source code file, containing the public class test, to successfully compile, which of the following must be true?

A. It must have a package statement
B. It must be named test.java
C. It must import java.lang
D. It must declare a public class named test.
Answer» B. It must be named test.java
216.

Which of the following are true about the Error and Exception classes?

A. Both classes extend throwable
B. The error class is final and exception class is not.
C. The Exception class is final and the Error is not.
D. Both classes implement Throwable
Answer» A. Both classes extend throwable
217.

Which of the following are true?

A. The void class extends the class class
B. The float class extends double class
C. The system class extends the runtime class
D. The integer class extends the number class
Answer» D. The integer class extends the number class
218.

How do you create a Reader object from an InputStream object?

A. Use the static createReader() method of InputStream class
B. Use the static createReader() method of Reader class
C. Create an InputStreamReader object passing the InputStream object and an argument to the InputStreamReader constructor.
D. Create an OutputStreamReader object, passing the InputStream object as an argument to the OutputStreamReader constructor.
Answer» C. Create an InputStreamReader object passing the InputStream object and an argument to the InputStreamReader constructor.
219.

Which of the following is true?

A. The event inheritance model has replaced the event delegation model
B. The event inheritance model is more efficient than event delegation model
C. The event delegation model uses event listeners to define the methods of event handling classes.
D. The event delegation model uses the handleEvent() method to support event handling.
Answer» C. The event delegation model uses event listeners to define the methods of event handling classes.
220.

Which of the following is the highest class in the event delegation model?

A. java.util.EventListner
B. java.util.EventObject
C. java.util.AWTEvent
D. java.util.event.AWTEvent
Answer» B. java.util.EventObject
221.

When two or more objects are added as listeners for the same event, which listener is first invoked to handle the event?

A. The first object that was added as listner.
B. The last object that was added as listner
C. There is no way to determine which listener will be invoked first.
D. It is impossible to have more than one listener for a given event.
Answer» C. There is no way to determine which listener will be invoked first.
222.

Suppose that you want to have an object eh handle the TextEvent of TextArea object t. How should you add eh as the event handler for?

A. t.addTextListener(eh);
B. eh.addTextListner(t);
C. addTextListner(eh.t);
D. addTextListner(t,eh);
Answer» D. addTextListner(t,eh);
223.

Which is true about an anonymous inner class?

A. It can extend exactly one class and implement exactly one interface.
B. It can extend exactly one class and can implement multiple interfaces.
C. It can extend exactly one class or implement exactly one interface.
D. It can implement multiple interfaces regardless of whether it also extends a class.
Answer» C. It can extend exactly one class or implement exactly one interface.
224.

Which is true about a method-local inner class?

A. It must be marked final.
B. It can be marked abstract.
C. It can be marked public.
D. It can be marked static.
Answer» B. It can be marked abstract.
225.

Which statement is true about a static nested class?

A. You must have a reference to an instance of the enclosing class in order to instantiate it.
B. It does not have access to nonstatic members of the enclosing class.
C. It's variables and methods must be static.
D. It must extend the enclosing class.
Answer» B. It does not have access to nonstatic members of the enclosing class.
226.

Which of these is correct way of inheriting class A by class B?

A. class B + class A {}
B. class B inherits class A {}
C. class B extends A {}
D. class B extends class A {}
Answer» C. class B extends A {}
227.

Which of the following are true about interfaces.

A. Methods declared in interfaces are implicitly private.
B. Variables declared in interfaces are implicitly public, static, and final.
C. An interface contains any number of method definitions.
D. The keyword implements indicate that an interface inherits from another.
Answer» B. Variables declared in interfaces are implicitly public, static, and final.
228.

Which of the following is correct way of implementing an interface salary by class manager?

A. class Manager extends salary {}
B. class Manager implements salary {}
C. class Manager imports salary {}
D. None of the mentioned.
Answer» B. class Manager implements salary {}
229.

Which of the following is incorrect statement about packages?

A. Package defines a namespace in which classes are stored.
B. A package can contain other package within it.
C. Java uses file system directories to store packages.
D. A package can be renamed without renaming the directory in which the classes are stored.
Answer» D. A package can be renamed without renaming the directory in which the classes are stored.
230.

Which exception is thrown by read() method?

A. IOException
B. InterruptedException
C. SystemException
D. SystemInputException
Answer» A. IOException
231.

Which method in Thread class is used to check weather a thread is still running?

A. isAlive()
B. Join()
C. isRunning()
D. Alive()
Answer» A. isAlive()
232.

Which of these class contains the methods print() & println()?

A. System
B. System.out
C. BufferedOutputStream
D. PrintStream
Answer» D. PrintStream
233.

To design a general-purpose search method, searchList, to search a list, which of the following must be parameters of the method searchList? (i) The array containing the list. (ii) The length of the list. (iii) The search item. (iv) A boolean variable indicating whether the search is successful.

A. (i) and (ii)
B. (i), (ii), and (iii)
C. (ii), (iii), and (iv)
D. (i), (ii), (iii), and (iv)
Answer» B. (i), (ii), and (iii)
234.

Consider the following list.list = {24, 20, 10, 75, 70, 18, 60, 35} Suppose that list is sorted using the selection sort algorithm as discussed in the book. What is the resulting list after two passes of the sorting phase, that is, after two iteration of the outer for loop?

A. list = {10, 18, 24, 20, 75, 70, 60, 35}
B. list = {10, 18, 20, 24, 75, 70, 60, 35}
C. list = {10, 18, 24, 75, 70, 20, 60, 35}
D. None of these
Answer» C. list = {10, 18, 24, 75, 70, 20, 60, 35}
235.

Which method would you most likely use to add an element to an end of a vector?

A. insertElementAt
B. addElement
C. copyInto
D. lastElement
Answer» B. addElement
236.

In which package is the class Vector located?

A. java.io
B. java.lang
C. java.util
D. java.text
Answer» C. java.util
237.

An abstract method ____.

A. is any method in the abstract class
B. cannot be inherited
C. has no body
D. is found in a subclass and overrides methods in a super-class using the reserved word abstract
Answer» C. has no body
238.

The classes Reader and Writer are derived from the class _________.

A. Streams
B. Inputs
C. Outputs
D. Object
Answer» D. Object
239.

The method toString() is a public member of the class _____________.

A. Object
B. String
C. Writer
D. Output
Answer» A. Object
240.

For the interface WindowListener that contains more than one method, Java provides the class ____.

A. MouseAdapter
B. WindowAdapter
C. KeyListener
D. KeyAdapter
Answer» B. WindowAdapter
241.

If a negative value is used for an array index, ____.

A. a NumberFormatException is thrown
B. the program terminates immediately
C. the last index of the array is automatically accessed instead
D. an IndexOutOfBoundsException is thrown
Answer» D. an IndexOutOfBoundsException is thrown
242.

Consider the following list. int[] intList = {35, 12, 27, 18, 45, 16, 38}; What is the minimum number of comparisons that have to be made to find 18 using a sequential search on intList?

A. 1
B. 2
C. 3
D. 4
Answer» D. 4
243.

Which of these packages contains all the classes and methods required for even handling in Java?

A. java.applet
B. java.awt
C. java.event
D. java.awt.event
Answer» D. java.awt.event
244.

What is an event in delegation event model used by Java programming language?

A. An event is an object that describes a state change in a source.
B. An event is an object that describes a state change in processing.
C. An event is an object that describes any change by the user and system.
D. An event is a class used for defining object, to create events.
Answer» A. An event is an object that describes a state change in a source.
245.

Which of these methods are used to register a keyboard event listener?

A. KeyListener()
B. addKistener()
C. addKeyListener()
D. eventKeyboardListener()
Answer» C. addKeyListener()
246.

Which of these methods are used to register a mouse motion listener?

A. addMouse()
B. addMouseListener()
C. addMouseMotionListner()
D. eventMouseMotionListener()
Answer» C. addMouseMotionListner()
247.

What is a listener in context to event handling?

A. A listener is a variable that is notified when an event occurs.
B. A listener is a object that is notified when an event occurs.
C. A listener is a method that is notified when an event occurs.
D. None of the mentioned
Answer» B. A listener is a object that is notified when an event occurs.
248.

Which command disassembles a class file

A. javaamd
B. javacmd
C. java
D. javap
Answer» D. javap
249.

JDBC stands for:

A. Java Database Connectivity
B. Java Database Components
C. Java Database Control
D. None of the above is correct.
Answer» A. Java Database Connectivity
250.

Which of the following statements is false as far as different type of statements is concern in JDBC?

A. Regular Statement
B. Prepared Statement
C. Callable Statement
D. Interim Statement
Answer» D. Interim Statement

Done Studing? Take A Test.

Great job completing your study session! Now it's time to put your knowledge to the test. Challenge yourself, see how much you've learned, and identify areas for improvement. Don’t worry, this is all part of the journey to mastery. Ready for the next step? Take a quiz to solidify what you've just studied.