what is the output?? class practice { static short type; public SuperTest(int a) { type = (short)a; } public static void manip(int delta) { type += delta; } } public class JavaTest extends SuperTest { int item; private JavaTest(int a) { super(a); item = a; } public static void manip(int delta) { type -= delta; } public int getTotal() { return item+type; } public static void main(String[] args) { SuperTest bob = new JavaTest(10); bob.manip(5); int num = ((JavaTest)bob).getTotal(); JavaTest tim = new JavaTest(num); tim.manip(12); System.out.println(tim.getTotal()); } }
what is the output??
class practice
{
static short type;
public SuperTest(int a)
{
type = (short)a;
}
public static void manip(int delta)
{
type += delta;
}
}
public class JavaTest extends SuperTest
{
int item;
private JavaTest(int a)
{
super(a);
item = a;
}
public static void manip(int delta)
{
type -= delta;
}
public int getTotal()
{
return item+type;
}
public static void main(String[] args)
{
SuperTest bob = new JavaTest(10);
bob.manip(5);
int num = ((JavaTest)bob).getTotal();
JavaTest tim = new JavaTest(num);
tim.manip(12);
System.out.println(tim.getTotal());
}
}
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images