Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java lab questions: For every code, the questions are commented out inside the code with // package q06; public class Main { public static void

Java lab questions:

For every code, the questions are commented out inside the code with //

package q06;

public class Main {

public static void main(final String[] argv) {

//implement the necessary interface and abstract class hierarchy

// B::foo

// B::foo

// B::foo

I ib = new B();

A ab = new B();

B bb = new B();

go(ib);

go(ab);

go(bb);

}

private static void go(final I i) {

i.foo();

}

}

package q07;

public class Main {

public static void main(final String[] argv) {

//implement the necessary interface, and abstract class hierarchy

//NOTE: Class A must be unimplemented, meaning it has an empty body

// B::foo

// B::foo

// B::foo

I ib = new B();

A ab = new B();

B bb = new B();

go(ib);

go(ab);

go(bb);

}

private static void go(final I i) {

i.foo();

}

}

package q08;

public class Main {

public static void main(final String[] argv) {

//implement the necessary interface, and abstract class hierarchy

//NOTE: Class B must be unimplemented, meaning it has an empty body

// A::foo

// A::foo

// A::foo

I ib = new B();

A ab = new B();

B bb = new B();

go(ib);

go(ab);

go(bb);

}

private static void go(final I i) {

i.foo();

}

}

package q09;

public class Main {

public static void main(String[] args) {

//implement the necessary abstract class hierarchy

//NOTE: Star does not extend any of the other classes, only Object

// Bar::go

// Car::go

// Star::go

// Bar::go

// Bar::go

// Bar::go

// Car::go

// Star::go

Foo a = new Bar();

Foo b = new Car();

Foo c = new Star();

AbstractFoo d = new Bar();

AbstractFoo e = new Bar();

Bar f = new Bar();

Bar g = new Car();

Star h = new Star();

a.go();

b.go();

c.go();

d.go();

e.go();

f.go();

g.go();

h.go();

}

}

interface Foo {

void go();

}

package q10;

public class Main {

public static void main(String[] args) {

//implement the necessary abstract class hierarchy

// Bar::go

// Bar::away

// Car::go

// Car::away

// Bar::go

// Bar::away

// Car::go

// Car::away

// Car::go

// Car::away

AbstractFoo a = new Bar();

AbstractFoo b = new Car();

Bar c = new Bar();

Bar d = new Car();

Car e = new Car();

a.go();

a.away();

b.go();

b.away();

c.go();

c.away();

d.go();

d.away();

e.go();

e.away();

}

}

interface Foo {

void go();

}

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

The Database Relational Model A Retrospective Review And Analysis

Authors: C. J. Date

1st Edition

0201612941, 978-0201612943

More Books

Students also viewed these Databases questions

Question

How autonomous should the target be left after the merger deal?

Answered: 1 week ago