Analyzing the code-running the program


Discussion:

Q: Access the extends3 Java program. Code, compile, and run the program. There are five lines of code marked (1)..(5) that you must explain after analyzing the code, running the program, and examining the output.import java.io.*;

import java.awt.*;
import java.lang.*;

public class extends3
{

public static void main(String[] jim) throws IOException
{
class Parent
{
private int size = 5;

void bumpsize() //Parent method which is public by default // (1)
{
System.out.println();
System.out.println("Parent size is "+ size);
size++;
System.out.println();
System.out.println("Parent size is " + size);
}
}//end Parent
class Son extends Parent // (2)
{
}// end Son

Son joe = new Son(); // (3)
joe.bumpsize(); // (4)
joe.bumpsize();
//joe.size = 15; creates a compiler error // (5)


} //end main

} //end class

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Analyzing the code-running the program
Reference No:- TGS01935910

Now Priced at $20 (50% Discount)

Recommended (98%)

Rated (4.3/5)