Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

0782125395, 9780782125399

More Books

Students also viewed these Databases questions

Question

What is a graph in programming?

Answered: 1 week ago