Question: Question 3. Given: public class Literally { public static void main(String[] args) { int i1 = 1_000; // line A int i2 = 10_00; //
Question 3.
Given:
public class Literally { public static void main(String[] args) { int i1 = 1_000; // line A int i2 = 10_00; // line B int i3 = _10_000; // line C int i4 = 0b101010; // line D int i5 = 0B10_1010; // line E int i6 = 0x2_a; // line F } }
Which lines WILL NOT compile? (Choose all that apply.)
A. Line A
B. Line B
C. Line C
D. Line D
E. Line E
F. Line F
Answer :
C is correct; line C will NOT compile. As of Java 7, underscores can be included in numeric literals, but not at the beginning or the end. A, B, D, E, and G are incorrect. A and B are legal numeric literals. D and E are examples of valid binary literals, which are also new to Java 7, and G is a valid hexadecimal literal that uses an underscore. (OCA Objective 2.1 and Upgrade Objective 1.2)
Required :
please explain why answer is correct and why others are not? please explain the program?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
