What is the result?

Given:

What is the result?

Given:

What is the result?

A.
Compilation fails at line n3 and line n4.

B.
Compilation fails at line n1 and line n2.

C.
Welcome Visit Count:1
Welcome Visit Count: 2

D.
Welcome Visit Count:1
Welcome Visit Count: 2



Leave a Reply 4

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


Mick B

Mick B

Compilation fails at line n1 & n2.
A non static field cannot be referenced from a static context.
If you created an object of class App such as

App a = new App();
a.count++
System.out.println(“Welcome “+”Visit Count: “+a.count);

would compile fine and print

Welcome Visit Count: 1
Welcome Visit Count: 1

jeronimo

jeronimo

supongo que la variable tiene que ser static . la B