Professional Documents
Culture Documents
java-mcq
java-mcq
a) Byte
b) long
c) Boolean
d) String
3. What is process by which one object acquires all the properties and behaviors of another
objects?
a) Inheritance
b) Polymorphism
c) Abstraction
d) Encapsulation
a) IOException
b) SQLException
c) NullPointerException
d) FileNotFoundException
5. Which of the following keyword is used to derive child interface from parent interface?
a) Package
b) import
c) extends
d) implements
6. What is process when two or more threads need to access share resource, they need some way
to ensure that resource will used by only one thread at a time?
a) Deadlock
b) Synchronization
c) Interthread communication
d) Starvation
7. Which of the following class is used to read data from file in character Stream?
a) FileInputStream
b) FileOutputStream
c) FileReader
d) FileWriter
a) hasNext()
b) next()
c) remove()
d) empty()
9. What is name of swing control that is normally display one entry and act as dropdown list?
a) JList
b) JComboBox
c) JRadioButto
d) JCheckBox
10. Which of the following JDBC component is used to handle communication with database
server?
a) DriverManager
b) Driver
c) Connection
d) SQLException
11. Which one of the following is not a valid java bitwise operator?
a) >>
b) <<
c) >>>
d) <<<
a) throws
b) thow
c) try
d) catch
a) private
b) protected
c) public
d) default
15. Which one of the following is not a collection class defined in java?
a) LinkedList
b) HashSet
c) TreeSet
d) GraphSet
16. Which of the following inheritance is best implanted using interface in java?
a) Single inheritance
b) Multilevel inheritance
c) Multiple inheritance
d) Hierarchical inheritance
17. Which of the following method is called only once during the run time of your applet?
a) stop()
b) paint()
c) init
d) start()
18. Which of these method of class String is used to compare two String object for their equality?
a) equals()
b) Equals()
c) isEquals()
d) IsEqual()
19. What is the default value of priority variable MIN_PRIORITY and MAX_PRIORITY?
a) 0 & 63
b) 1 & 10
c) 0 & 1
d) 1 & 32
a) Panel
b) Tabbed Pane
c) Scroll Pane
d) Scroll bar
a) >>
b) >>>
c) ++
d) ?:
a) super
b) constant
c) global
d) final
a) Boolean
b) default
c) this
d) implicit
24. Which of these operators can skip evaluating right hand operand?
a) ^
b) |
c) &
d) &&
a) try
b) finally
c) throw
d) catch
26. The method that returns a string associated with GUI Button is ......
a) getSource() method
b) setSource() method
c) getActionCommand() method
d) setActionCommand() method
27. Which of the following is the container that doesn't contain a title bar and menu bar but it can
have other GUI components such as buttons and text fields.
a) Window
b) Frame
c) Panel
d) Menu
28. Which of the following classes is defined in javax.swing package?
a) Button
b) JButton
c) Applet
d) Frame
29. Which method is automatically called after browser calls the init method?
a) start
b) stop
c) destroy
d) paint
a) java.util
b) java.file
c) java.io
d) java.lang
a) Polymorphism
b) Abstraction
c) Inheritance
d) Encapsulation
a) explicit
b) implicit
c) protected
d) public
33. A constructor ...
a) small class
b) subclass
c) noticeable class
d) big class
35. Which of these attributes can we use if we want to get the actual size of any array?
a) Array_name.length
b) Size.array
c) length_Array_name
d) Array.Size
36. Which function is used to get any character that is present at a certain index of a string?
b) char charAt(index)
c) char charIn(index)
d) char charAt(StringName)
37. What is character encoding scheme used for char type in java?
a) TSCII
b) ASCII
c) UNICODE
d) EBCDIC
38. Which is the super class of all java classes?
a) Class
b) Object
c) System
d) JVM
a) this
b) super
c) final
d) main
a) StringIndexOutOfBounds
b) NullPointer
c) IllegalIndexAccess
d) InvalidIndex
a) Serialization
b) Deserialization
c) synchronization
d) none of these
42. Which of these classes is used to read file in the form of byte sequence?
a) FileInputStream
b) FileOutputStream
c) FileReader
d) FileWriter
43. A package is a collection of ...
a) class
b) interface
d) java programs
44. All classes and interfaces of event are defined in ... package.
a) java.awt.*
b) java.awt.event.*;
c) java.event.*
d) java.swing.*
45. Which of these methods of thread class is used to suspend a thread for a period of time?
a) sleep()
b) terminate()
c) suspend()
d) stop()
46. ... Layout used to arrange the components in a line one after the other?
a) FlowLayout
b) BorderLayout
c) GridLayout
d) GridBackLayout
a) ==
b) equals
c) instanceof
d) object
48. ... type exception caused when a conversion between string & number fails.
a) ArithmeticException
b) NumberFormatException
c) IOException
d) InterruptedException
a) float f=1.0f
b) float f=1.0
c) float f="1"
d) float f=1.0d