What is the result?

Given:
10: public class Hello {
11: String title;
12: int value;
13: public Hello() {
14: title += ” World”;
15: }
16: public Hello(int value) {
17: this.value = value;
18: title = “Hello”;
19: Hello();
20: }
21: }
and:
30: Hello c = new Hello(5);
31: System.out.println(c.title);
What is the result?

Given:
10: public class Hello {
11: String title;
12: int value;
13: public Hello() {
14: title += ” World”;
15: }
16: public Hello(int value) {
17: this.value = value;
18: title = “Hello”;
19: Hello();
20: }
21: }
and:
30: Hello c = new Hello(5);
31: System.out.println(c.title);
What is the result?

A.
The code runs with no output.

B.
Hello

C.
Hello World 5

D.
Compilation fails.

E.
An exception is thrown at runtime.

F.
Hello World



Leave a Reply 0

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