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
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
Test 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
B
supongo que la variable tiene que ser static . la B