Exercise for methods and classes

 

Main.java      ClassA.java         ClassB.java

 

 

public class Main

{

    public static void main (String args[]) {

     System.out.println("entering main():");

     ClassA objA = new ClassA();

     objA.method1ClassA();

     System.out.println("exiting main() ...");

    } // main()

} // end class Main

 

public class ClassA

{

     int int1 = 1;

 

     public void method1ClassA( ) {

           System.out.println("\tentering method1ClassA() ...");

          System.out.printf("\tmethod1ClassA(): int1 = %d\n", int1);

 

           ClassB objB = new ClassB();

           objB.method1ClassB();

           System.out.println("\texiting method1ClassA() ...");

     } // method1ClassA()

 

} // end class ClassA

 

 

public class ClassB

{

     int int2 = 2;

 

     public void method1ClassB( ) {

           System.out.println("\t\tentering method1ClassB():");

           System.out.printf("\t\tmethod1ClassB(): int2 = %d\n", int2);

           System.out.println("\t\texiting method1ClassB() ...");

     } // method1ClassB()

 

} // end class ClassB