Question

Java CSE 135 Which methods does the ChoiceQuestion class inherit from its superclass? Which methods does...

Java CSE 135

Which methods does the ChoiceQuestion class inherit from its superclass? Which methods does it override? Which methods does it add?

public class Question{ . . . public void display() { System.out.println(text); }} public class ChoiceQuestion extends Question{ . . . public void display() { super.display(); for (int i = 0; i < choices.size(); i++) { int choiceNumber = i + 1; System.out.println(choiceNumber + ": " + choices.get(i)); } }} public class QuestionDemo{ public static void main(String[] args) { Question q1 = new Question(); ChoiceQuestion q2 = new ChoiceQuestion(); . . . presentQuestion(q1); presentQuestion(q2); . . . }  public static void presentQuestion(Question q) { q.display(); . . . }}

0 0
Add a comment Improve this question Transcribed image text
Answer #1
Question class has only one method named display.
ChoiceQuestion inherits from Question class.

Which methods does the ChoiceQuestion class inherit from its superclass? 
display method.

Which methods does it override?
display method. 

Which methods does it add?
None. display method created in ChoiceQuestion overrides the method from Question class. So, technically it is not a newly added method of ChoiceQuestion class.
Add a comment
Know the answer?
Add Answer to:
Java CSE 135 Which methods does the ChoiceQuestion class inherit from its superclass? Which methods does...
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
  • What is wrong with the following Java Code. public class TestEdible { abstract class Animal {...

    What is wrong with the following Java Code. public class TestEdible { abstract class Animal { /** Return animal sound */ public abstract String sound(); } class Chicken extends Animal implements Edible { @Override public String howToEat() { return "Chicken: Fry it"; } @Override public String sound() { return "Chicken: cock-a-doodle-doo"; } } class Tiger extends Animal { @Override public String sound() { return "Tiger: RROOAARR"; } } abstract class Fruit implements Edible { // Data fields, constructors, and methods...

  • help me with a question in java: class A { int i = 10; } class...

    help me with a question in java: class A { int i = 10; } class B extends A { int i = 20; } public class Boo { public static void main(String[] args) { A a = new B(); System.out.println(a.i); } }

  • Java questions QUESTION 8 Assume the following classes are each defined in their own java files...

    Java questions QUESTION 8 Assume the following classes are each defined in their own java files and compile public class A public void display { System.out.println("A's display"); public class B extends A{ public void display { System.out.println("B's display"); public class C extends A public void display { System.out.println("C's display"); public class D { public static void main(String args) { 3: int i = ((int)(Moth.random(* 10)) if (i == 0) a = new BO: else if (i == 1) a =...

  • The method m() of class B overrides the m() method of class A, true or false?...

    The method m() of class B overrides the m() method of class A, true or false? class A int i; public void maint i) { this.is } } class B extends A{ public void m(Strings) { 1 Select one: True False For the following code, which statement is correct? public class Test { public static void main(String[] args) { Object al = new AC: Object a2 = new Object(); System.out.println(al); System.out.println(a): } } class A intx @Override public String toString()...

  • Intro to Java - Assignment JAVA ASSIGNMENT 13 - Object Methods During Event Handling Assignment 13...

    Intro to Java - Assignment JAVA ASSIGNMENT 13 - Object Methods During Event Handling Assignment 13 Assignment 13 Preparation This assignment will focus on the use of object methods during event handling. Assignment 13 Assignment 13 Submission Follow the directions below to submit Assignment 13: This assignment will be a modification of the Assignment 12 program (see EncryptionApplication11.java below). Replace the use of String concatenation operations in the methods with StringBuilder or StringBuffer objects and their methods. EncryptTextMethods.java ====================== package...

  • What is the output of this program? class A { public int i; private int j;...

    What is the output of this program? class A { public int i; private int j; } class B extends A { void display() { super.j = super.i + 1; System.out.println(super.i + " " + super.j); } } class Inheritance { public static void main(String args[]) { B obj = new B(); obj.i=1; obj.j=2; obj.display(); } } Java language!! // include explanation!

  • 1) Consider the following Java program: 1 public class HelloWorld { 2     // My first program!...

    1) Consider the following Java program: 1 public class HelloWorld { 2     // My first program! 3     public static void main(String[] args) { 4         System.out.println("Hello, World!"); 5     } 6 } What is on line 1? a. a variable declaration b. a statement c. a method (subroutine) definition d. a comment e. a class definition 2) Which one of the following does NOT describe an array? a. It can be used in a for-each loop. b. It has a numbered sequence...

  • **JAVA*JAVA Question 1 How many k's values will be printed out? public static void main(Stringl args)...

    **JAVA*JAVA Question 1 How many k's values will be printed out? public static void main(Stringl args) for (int k-1: k10:k if (k8) continue: System.out.println k) Question 2 3.5 pts Analyze the following code. Which one is correct? package p public class A package p2: import p1. public class B extends Af int i- 5 private int j- 10: public A0I public static void main(Stringll args) B b new B0: System.out.println(a.i+", "+ajt", "+b.it""+bj): a.i is printable None of them b.i is...

  • What is the output for the following program codes? a) [ 0.5 Mark ] class A...

    What is the output for the following program codes? a) [ 0.5 Mark ] class A { int i; } class B extends A { int j; void display() { super.i = j + 1; System.out.println(j + " " + i); }} class inheritance { public static void main(String args[]) { B obj = new B(); obj.i=1; obj.j=2; obj.display(); }} OUTPUT: b) [ 0.5 Mark ] class Parent { public void getBike(){ System.out.println("Suzuki Bike"); }} class Child extends Parent {...

  • Need help with this Java question in 1 hour please JAVA Using the files from the...

    Need help with this Java question in 1 hour please JAVA Using the files from the in-class assignment add two additional animals of your choice. For each animal add two additional methods appropriate to your particular animal. As the majority of the code for this program exists you will not need an algorithm. Use the 3 java classes below. Thank you //Animal.java public class Animal {    public Animal() {    System.out.println("A new animal has been created!");    }   ...

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