Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Java lab questions: For every code, the questions are commented out inside the code with // 6. package q06; public class Main { public static
Java lab questions:
For every code, the questions are commented out inside the code with //
6. 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(); } }
7. 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(); } }
8. 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(); } } }
9. 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(); }
10. 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started