Important Java Mcq 1

Which of the following is illegal in Java?

a. int i = 32;

b. double  d = 30.0;

c. float f = 30.0;

d. string s = “hello”;

Answer:

c. float f = 30.0;

Explanation

In option c, 30.0 is a double value and it was declared as a floating point value. The above option would be legal if it was declared as float f = 30.0f;.

Related MCQs
Aniket Malik

Aniket Malik

CERTIFIED TUTOR/TRAINER WITH 300+ REVIEWS

Facing difficulty with

this concept?