Top 250+ Solved Java Programming MCQ Questions Answer
Q. Which concept of Java is a way of converting real world objects in terms of class?
a. Polymorphism
b. Encapsulation
c. Abstraction
d. Inheritance
Q. How can we identify whether a compilation unit is class or interface from a .class file?
a. Java source file header
b. Extension of compilation unit
c. We cannot differentiate between class and interface
d. The class or interface name should be postfixed with unit type
Q. Which of these packages contains abstract keyword?
a. javlang
b. java.util
c. java.io
d. java.system
Q. Which of these class is used to create an object whose character sequence is mutable?
a. String()
b. StringBuffer()
c. String() & StringBuffer()
d. None of the mentioned
Q. Which of these method of class StringBuffer is used to find the length of current charactersequence?
a. length()
b. Length()
c. capacity()
d. Capacity()
Q. Which of these method(s) is/are used for writing bytes to an outputstream?
a. put()
b. print() and write()
c. printf()
d. write() and read()
Q. Which keyword is used by the method to refer to the object that invoked it?
a. import
b. catch
c. abstract
d. this
Q. What is the return type of a method that does not return any value?
a. int
b. float
c. void
d. double
Q. Which of these selection statements test only for equality?
a. if
b. switch
c. if & switch
d. none of the mentioned
Q. Which of these jump statements can skip processing the remainder of the code in its body fora particular iteration?
a. break
b. return
c. exit
d. continue
Q. Which of these is the method which is executed first before execution of any other thing takesplace in a program?
a. main method
b. finalize method
c. static method
d. private method
Q. Which of these data type can be used for a method having a return statement in it?
a. void
b. int
c. float
d. both int and float
Q. If an expression contains double, int, float, long, then the whole expression will be promotedinto which of these data types?
a. long
b. int
c. double
d. float