Question: Question 1: Assuming that the following classes have been defined: public class A { public static void method1() { System.out.println(A1); } } public class B

Question 1:

Assuming that the following classes have been defined:

public class A

{

public static void method1()

{

System.out.println("A1");

}

}

public class B extends A

{

public static void method2()

{

System.out.println("B2");

}

}

public class C extends B

{

public static void method1()

{

System.out.println("C1");

}

}

And assuming the following objects have been defined:

A a = new A();

B b = new B();

B other2 = new C();

In the table below, indicate in the right-hand column the output produced by the statement in the left-hand column. If the statement causes an error, fill in the right-hand column with either the phrase "compiler error" or "runtime error" to indicate when the error would be detected.

Statement Output

---------------------------------------------------------------------

a.method1(); __________________

a.method2(); __________________

b.method1(); __________________

b.method2(); __________________

other2.method1(); __________________

other2.method2(); __________________

Question 2:

Write Java code to create a new class called Student. An object of the Student class has private attributes - student id, name and address. Instantiate an array object of this class, with these attributes (for 2 objects). Thereafter, display these attributes to a user. (Your code should include entire class and a driver to demonstrate the above).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!