01. Example:
class firstClass { firstClass() { System.out.println("Constructor of first class."); } void firstClassMethod() { System.out.println("Method of first class."); } public static void main(String[] args) { firstClass firstClassObject = new firstClass(); secondClass secondClassObject = new secondClass(); firstClassObject.firstClassMethod(); secondClassObject.secondClassMethod(); } } class secondClass { secondClass() { System.out.println("Constructor of second class."); } void secondClassMethod() { System.out.println("Method of second class."); } }
Output:
Constructor of first class.
Constructor of second class.
Method of first class.
Method of second class.