Which statement is true?

Given the content of three files: Which statement is true?

Given the content of three files: Which statement is true?

A.
The A.Java and B.java files compile successfully.

B.
The B.java and C.java files compile successfully.

C.
The A.Java and C.java files compile successfully.

D.
Only the B.java file compiles successfully.

E.
Only the A.Java file compiles successfully.

F.
Only the C.java file compiles successfully.



Leave a Reply 10

Your email address will not be published. Required fields are marked *


TC

TC

C is the Right answer

Kaykay

Kaykay

Correct Answer is E. Only A compiles successfully.

Access Modifier is not allowed on a local variable in Class B.
Rule for Local Variable
– Local variables cannot use any of the access level since its scope is only inside the method.
– Final is the Only Non Access Modifier that can be applied to a local variable.
– Local variables are not assigned a default value, hence they need to be initialised.

Class C has statements in the wrong order…Correct order is Package,Import and Class (PIC).

Narayana Gowda

Narayana Gowda

Yes, option E is correct answer. thanks for detailed explanation.

Kumaresh Babu

Kumaresh Babu

thnx bro 🙂

Tomas

Tomas

Answer: E
Only the A.Java file compiles successfully.
Tested