159
87k

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 .

51.

A primitive data type can be passed as an argument into a method

A. By value
B. by reference
C. both a & b
D. none of these
Answer» A. By value
52.

Which of these is used as default for a member of a class if no access specifier is used for it?

A. private
B. public
C. public, within its own package
D. protected
Answer» C. public, within its own package
53.

Which of these keywords is used to refer to member of base class from a sub class?

A. upper
B. super
C. this
D. None of the mentioned
Answer» B. super
54.

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 {}
55.

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.
56.

Which of these keywords is used to define interfaces in Java?

A. interface
B. Interface
C. intf
D. implements
Answer» A. interface
57.

Which of these can be used to fully abstract a class from its implementation?

A. Objects
B. Packages
C. Interfaces
D. None of the Mentione
Answer» C. Interfaces
58.

Which of these access specifiers can be used for an interface?

A. Public
B. Protected
C. private
D. All of the mentioned
Answer» A. Public
59.

Which of these keywords is used by a class to use an interface defined previously?

A. import
B. Import
C. implements
D. Implements
Answer» C. implements
60.

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 {}
61.

The keyword used to create a package is

A. import
B. package
C. classpath
D. public
Answer» B. package
62.

The modifier which specifies that the member can only be accessed in its own class is

A. public
B. private
C. protected
D. none
Answer» B. private
63.

Which of the following package stores all the standard java classes? a) jav

A. lang
B. java
C. java.util
D. java.packages
Answer» A. lang
64.

Which of these is a mechanism for naming and visibility control of a class and its content?

A. Object
B. Packages
C. Interfaces
D. None of the Mentioned
Answer» B. Packages
65.

Which of this access specifies can be used for a class so that its objects can be created by a different class in another package?

A. Public
B. Protected
C. No Modifier
D. All of the mentioned
Answer» A. Public
66.

Which of the following is correct way of importing an entire package ‘pkg’?

A. import pkg.
B. Import pkg.
C. import pkg.*
D. Import pkg.*
Answer» C. import pkg.*
67.

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.
68.

Which of these method of class String is used to extract a single character from a String object?

A. CHARAT()
B. chatat()
C. charAt()
D. ChatAt()
Answer» C. charAt()
69.

Which of these method of class String is used to obtain length of String object?

A. get()
B. Sizeof()
C. lengthof()
D. length()
Answer» D. length()
70.

Which of these keywords is not a part of exception handling?

A. try
B. finally
C. thrown
D. catch
Answer» C. thrown
71.

The code within the ----------- block will always be executed whether or not an exception is thrown.

A. try..catch
B. finally
C. throw
D. throws
Answer» B. finally
72.

Which of these keywords must be used to monitor for exceptions?

A. try..catch
B. finally
C. throw
D. throws
Answer» A. try..catch
73.

Which of these keywords is used to manually throw an exception?

A. try
B. finally
C. throw
D. catch
Answer» C. throw
74.

Which of these classes is related to all the exceptions that can be caught by using catch?

A. Error
B. Exception
C. None of these
D. a & b
Answer» B. Exception
75.

Which of these classes is related to all the exceptions that cannot be caught?

A. Error
B. Exception
C. None of these
D. a & b
Answer» A. Error
76.

Which exception is thrown by read() method?

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

Which is the super class of all exception classes

A. Exception
B. Object
C. Error
D. Throwable
Answer» D. Throwable
78.

Which class is the super class of all classes of the java.lang package?

A. Object
B. System
C. Super
D. Class
Answer» A. Object
79.

Which of the following exception is raised when a number is divided by zero

A. NumberFormatException
B. ArithmeticException
C. NullPointerException
D. IllegalArgumentException
Answer» B. ArithmeticException
80.

A single try block must be followed by which of these?

A. finally
B. catch
C. catch or finally
D. None of the mentioned
Answer» C. catch or finally
81.

Which of these exceptions will occur if we try to access the index of an array beyond its length?

A. ArithmeticException
B. ArrayException
C. ArrayIndexException
D. ArrayIndexOutOfBoundsException
Answer» D. ArrayIndexOutOfBoundsException
82.

Runnable is a

A. Class
B. Method
C. Variable
D. Interface
Answer» D. Interface
83.

Thread priority in Java is represented as?

A. int
B. Float
C. double
D. long
Answer» A. int
84.

Which of these class is used to make a thread?

A. String
B. System
C. Thread
D. Runnable
Answer» C. Thread
85.

Which of these interface is implemented to create a Thread?

A. Runnable
B. Connections
C. Set
D. MapConnections
Answer» A. Runnable
86.

Which of these method of Thread class is used to find out the priority given to a thread?

A. get()
B. ThreadPriority()
C. getPriority()
D. getThreadPriority()
Answer» C. getPriority()
87.

Which of this method of Thread class is used to change the state of a thread to blocked state?

A. sleep()
B. terminate()
C. stop()
D. block()
Answer» A. sleep()
88.

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()
89.

Which of these methods is used to begin the execution of a thread?

A. run()
B. start()
C. runThread()
D. startThread()
Answer» B. start()
90.

Which of these method waits for the thread to treminate?

A. sleep()
B. isAlive()
C. join()
D. stop()
Answer» C. join()
91.

Which of these is used to read a string from the input stream?

A. get()
B. getLine()
C. read()
D. readLine()
Answer» D. readLine()
92.

Which of these classes is used to read characters and strings in Java from console?

A. BufferedReader
B. StringReader
C. BufferedStreamReader
D. InputStreamReader
Answer» D. InputStreamReader
93.

Which of these classes are used by Byte streams for input operation?

A. InputStream
B. InputOutputStream
C. Reader
D. All of the mentioned
Answer» A. InputStream
94.

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

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

Which of these methods can be used to write console output?

A. printout()
B. println()
C. write()
D. All of the mentioned
Answer» B. println()
96.

Which of these classes are used by character streams output operations?

A. OutputStream
B. Writer
C. ReadStream
D. InputOutputStream
Answer» B. Writer
97.

Which refers to a channel through which data flow from the source to the destination:

A. String
B. Character
C. Stream
D. Buffer
Answer» C. Stream
98.

Java Stream classes can be categorized into two groups:

A. Byte and Character Stream Classes
B. Stream and String Classes
C. String and Character Stream Classes
D. Buffer and Character Stream Classes
Answer» A. Byte and Character Stream Classes
99.

Byte Stream Classes support input/output operations on _____

A. 8 bit
B. 16 bit
C. 32 bit
D. 64 bit
Answer» A. 8 bit
100.

Character Stream Classes support input/output operations on _______ characters:

A. 8 bit Unicode
B. 16 bit Unicode
C. 32 bit Unicode
D. 64 bit Unicode
Answer» B. 16 bit Unicode

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.