Top 250+ Solved Java Programming MCQ Questions Answer

From 16 to 30 of 285

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

  • b. The destination type is larger than source type.

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

  • b. * operator has converted b * 50 into int, which can not be converted to byte without casting.

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

  • 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

  • b. switch

Q. Which of these are selection statements in Java?

a. if

b. for

c. continue

d. all of these

  • a. if

Q. What is the value of the expression 2 & 3 ?

a. 2

b. 3

c. 6

d. 5

Q. What is the value of the expression 8 << 2 ?

a. 2

b. 32

c. 1 6

d. 5

  • b. 32

Q. The keyword used to create a constant variable

a. const

b. static

c. final

d. none of these

  • c. final

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

  • b. NULL

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

  • c. class B extends 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.

  • b. Variables declared in interfaces are implicitly public, static, and final.

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

  • b. class Manager implements salary {}

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

  • d. A package can be renamed without renaming the directory in which the classes are stored.

Q. Which exception is thrown by read() method?

a. IOException

b. InterruptedException

c. SystemException

d. SystemInputException

  • a. IOException
Subscribe Now

Get All Updates & News