//in file A.java
package p1;
public class A
{
protected int i = 10;
public int getI() { return i; }
}
//in file B.java
package p2;
import p1.*;
public class B extends p1.A
{
public void process(A a)
{
a.i = a.i*2;
}
public static void main(String[] args)
{
A a = new B();
B b = new B();
b.process(a);
System.out.println( a.getI() );
}
}
Consider following two classes:
What will be the output of compiling and running class B ?
a. It will print 10.
b. It will print 20.
c. It will not compile.
d. It will throw an exception at Run time.
e. None of the above.
Ae galera … prometo q vai ser a ultima do dia ! rsrsrs
De novo … sem compilar … se naum perde a graca!!!
Valeu !!!