Question

JAVA CODING:

(14 points) Abstract Class exercise You are given two abstract classes with no abstract method in the NoGo.java file. The purpose of this exercise is to get familiar with abstract class and its object creation 4. Follow the steps below: (be sure common on each to score points) 1) 2) 3 points) Create a subclass Go1 with Nogo1 as its super class and create Go1() constructor 3) (2 points) Now inside the NoGo class create an instance of Go1, you should be able to run it. 4) (2 points) In Nogo2 class (abstract) add an abstract method as the following (2 points) Use the NoGo.java file to show that you cannot create any instances (reference variables) of these two classes that print a Go1() message What is the display? Please explain what happen abstract void nMethodl: 5 (2 points) Create a new class Go9 that extends the Nogo2 class and overrides the nMethod method. The constructor for Go9( displays Go9() (2 points) In Nogo2 class (abstract) add an abstract method as the following abstract void nMethod 6) Run NoGo program, You should see the following display:(1 points) NoGo1() Go1() Go9() get nMethod() out of abstraction

0 0
Add a comment Improve this question Transcribed image text
Answer #1

As NoGo1.java and No NoGo2.java was not given just created on the basic of requiremnt.
you can find the comment the section numberering in which explain the points from question.

//NoGo1.java

public abstract class NoGo1 {

    public NoGo1(){
        System.out.println("NoGo1()");
    }
}

//NoGo2.java
public abstract class NoGo2 {
    // 4. abstract method
    abstract void nMethod();
}


// Go1.java

// 3. Go1 class that extending NoGo1 abstract class
public class Go1 extends NoGo1 {

    public Go1(){
        super();
        System.out.println("Go1()");
    }
}


//Go9.java

// 5. Go9 that extending the NoGo2
public class Go9 extends NoGo2 {

    public Go9(){
        System.out.println("Go9()");
    }
    @Override
    void nMethod() {
        System.out.println("get nMethod() out of abstraction");
    }
}

//NoGo.java
public  class NoGo {


    public static void main(String[] args) {
       // 1) you cant create instance of abstract class
//        NoGo1 o1 = new NoGo1() ;
//        NoGo2 o2 = new NoGo2() ;
        // 3. creating the object of Go1 its constructor will call
        // NoGo1 class constructor and print NOGo1() first then
        // it will print Go1()
        Go1 obj = new Go1();
        Go9 obj1 = new Go9();
        obj1.nMethod();
    }
}


//OUTPUT
NoGo1()
Go1()
Go9()
get nMethod() out of abstraction
Add a comment
Know the answer?
Add Answer to:
JAVA CODING: (14 points) Abstract Class exercise You are given two abstract classes with no abstract...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In Java Which of the following statements declares Salaried as a subclass of payType? Public class...

    In Java Which of the following statements declares Salaried as a subclass of payType? Public class Salaried implements PayType Public class Salaried derivedFrom(payType) Public class PayType derives Salaried Public class Salaried extends PayType If a method in a subclass has the same signature as a method in the superclass, the subclass method overrides the superclass method. False True When a subclass overloads a superclass method………. Only the subclass method may be called with a subclass object Only the superclass method...

  • PRG/421 Week One Analyze Assignment – Analyzing a Java™Program Containing Abstract and Derived Classes 1.    What is...

    PRG/421 Week One Analyze Assignment – Analyzing a Java™Program Containing Abstract and Derived Classes 1.    What is the output of the program as it is written? (Program begins on p. 2) 2. Why would a programmer choose to define a method in an abstract class (such as the Animal constructor method or the getName()method in the code example) vs. defining a method as abstract (such as the makeSound()method in the example)? /********************************************************************** *           Program:          PRG/421 Week 1 Analyze Assignment *           Purpose:         Analyze the coding for...

  • In this lab you will work with abstract classes/interfaces. (Java Program) You will be implementing a...

    In this lab you will work with abstract classes/interfaces. (Java Program) You will be implementing a basic employee schema within a company. The Employee class will be an abstract class that will contain methods applicable to all employees. You will then create 2 classes called SoftwareEngineer and ProductManager. Both are different employee types based on occupation. You will create an interface called Developer which will consist of specific methods that apply to only Developers (e.g. SoftwareEngineer class will implement this,...

  • Java Problem 2: Employee (10 points) (Software Design) Create an abstract class that represents an Employee and contains abstract method payment. Create concrete classes: SalaryEmployee, CommissionEm...

    Java Problem 2: Employee (10 points) (Software Design) Create an abstract class that represents an Employee and contains abstract method payment. Create concrete classes: SalaryEmployee, CommissionEmployee, HourlyEmployee which extend the Employee class and implements that abstract method. A Salary Employee has a salary, a Commision Employee has a commission rate and total sales, and Hourly Employee as an hourly rate and hours worked Software Architecture: The Employee class is the abstract super class and must be instantiated by one of...

  • For Java, 1. What is an abstract method? How is an abstract method created? 2. What...

    For Java, 1. What is an abstract method? How is an abstract method created? 2. What is an abstract class? 3. Can an object of an abstract class be instantiated? 4. Does a superclass have access to the members of subclass? Does a subclass have access to the members of the superclass? 5. How do you prevent a subclass from having access to a member of a superclass? 6. Given the following hierarchy: class Alpha{ … class Beta extends Alpha...

  • java language Problem 3: Shape (10 points) (Software Design) Create an abstract class that represents a Shape and contains abstract method: area and perimeter. Create concrete classes: Circle, Rectang...

    java language Problem 3: Shape (10 points) (Software Design) Create an abstract class that represents a Shape and contains abstract method: area and perimeter. Create concrete classes: Circle, Rectangle, Triangle which extend the Shape class and implements the abstract methods. A circle has a radius, a rectangle has width and height, and a triangle has three sides. Software Architecture: The Shape class is the abstract super class and must be instantiated by one of its concrete subclasses: Circle, Rectangle, or...

  • JAVA Problem:  Coffee    Design and implement a program that manages coffees. First, implement an abstract class...

    JAVA Problem:  Coffee    Design and implement a program that manages coffees. First, implement an abstract class named Coffee. The Coffee class has three member variables: coffee type, price, and store name. The Coffee class has an abstract method name ingredient. Make sure to add all necessary setters and getters as well as other methods. The class Coffee implements an interface HowToMakeDrink. The interface has the following method: public interface HowToMakeDrink { public void prepare (); } The prepare method will...

  • This is a question about Java abstract classes. The correct answer is E and I do...

    This is a question about Java abstract classes. The correct answer is E and I do not understand why. Please be specific! I am a beginner in Java abstract classes and methods... 13.6 What is the output of running class Test? public class Test {   public static void main(String[] args) {     new Circle9();   } } public abstract class GeometricObject {   protected GeometricObject() {     System.out.print("A");   }   protected GeometricObject(String color, boolean filled) {     System.out.print("B");   } } public class Circle9 extends GeometricObject {...

  • Problem: Coffee(Java) Design and implement a program that manages coffees. First, implement an abstract class named...

    Problem: Coffee(Java) Design and implement a program that manages coffees. First, implement an abstract class named Coffee. The Coffee class has three member variables: coffee type(does not mention the data type of the variable coffeeType), price, and store name. The Coffee class has an abstract method name ingredient. Make sure to add all necessary setters and getters as well as other methods. The class Coffee implements an interface HowToMakeDrink. The interface has the following method: public interface HowToMakeDrink { public...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT