Which of the following lines will compile without errors and warnings?
float f = 1.3; // 1.3 constant is of type double. Therefore, 1.3f should be used
int i = 10; // Ok
char c = "a"; // Char constants should be written in single quotation marks: 'a';
byte b = 255; // byte range varies from -128 to 127
boolean b = null; // null value is acceptable only for reference types

Yes it gives an error when I write like boolean b = null

2017 Feb 24, 9:47:46 AM

Actually it should! Check it out : https://ideone.com/NIgAA4 . "boolean" is a primitive type, it can not be assigned with null value

2016 Jun 20, 3:26:18 PM

When I run boolean b = null I get no errors.

2016 Jun 16, 6:48:31 PM

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Продолжайте изучать
тесты по Java
Зарегистрируйся сейчас
или Подпишись на будущие тесты