What is the result?

Given:

final class FinalShow { // Line 1

final String location; // Line 2

FinalShow(final String loc) { // Line 3

location = loc; // Line 4

} // Line 5

FinalShow(String loc, String title) { // Line 6

location = loc; // Line 7

loc = “unknown”; // Line 8

} // Line 9

} // Line 10

What is the result?

Given:

final class FinalShow { // Line 1

final String location; // Line 2

FinalShow(final String loc) { // Line 3

location = loc; // Line 4

} // Line 5

FinalShow(String loc, String title) { // Line 6

location = loc; // Line 7

loc = “unknown”; // Line 8

} // Line 9

} // Line 10

What is the result?

A.
Compilation succeeds.

B.
Compilation fails due to an error on line 1.

C.
Compilation fails due to an error on line 2.

D.
Compilation fails due to an error on line 3.

E.
Compilation fails due to an error on line 4.

F.
Compilation fails due to an error on line 8.



Leave a Reply 5

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


a

a

F.
Compilation fails due to an error on line 8.
is correct as the final variable is initialized again .

Elaine

Elaine

A is correct, the final can be specified in constructor