Top 250+ Solved Java Programming MCQ Questions Answer
Q. Which of these is necessary condition for automatic type conversion in Java?
a. The destination type is smaller than source type.
b. The destination type is larger than source type.
c. The destination type can be larger or smaller than source type.
d. None of the mentioned
Q. What is the error in this code? byte b = 50; b = b * 50;
a. b can not store the result 2500, limited by its range.
b. * operator has converted b * 50 into int, which can not be converted to byte without casting.
c. b can not contain value 50.
d. No error in this code
Q. Which of these is an incorrect array declaration?
a. int arr[] = new int[5];
b. int [] arr = new int[5];
c. int arr[]; arr = new int[5];
d. int arr[] = int [5] new
Q. Which of these selection statements test only for equality?
a. if
b. switch
c. Both a & b
d. None of the mentioned
Q. Which of these jump statements can skip processing remainder of code in its body for a particular iteration?
a. break
b. return
c. exit
d. continue
Q. What is stored in the object obj in following lines of code? box obj;
a. Memory address of allocated memory of object.
b. NULL
c. Any arbitrary pointer
d. Garbage
Q. 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 {}
Q. 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.
Q. 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 mentione
Q. 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 store
Q. Which exception is thrown by read() method?
a. IOException
b. InterruptedException
c. SystemException
d. SystemInputException