zuai-logo
zuai-logo
  1. AP Computer Science A
FlashcardFlashcardStudy GuideStudy GuideQuestion BankQuestion Bank

Inheritance in Object-Oriented Programming

Question 1
college-boardComputer Science AAPExam Style
1 mark

For which reason might one deliberately choose not to use ‘super’ keyword whilst coding within subclass's methods?

Question 2
college-boardComputer Science AAPExam Style
1 mark

In what scenario would compiling fail due to improper use of 'super' keyword within a Java program containing several levels of inheritance?

Question 3
college-boardComputer Science AAPExam Style
1 mark

Given the block of code below, answer the following question:

java
class Shape {
    // constructor not shown

    public void draw() {
        System.out.println("Drawing a shape");
    }
}

class Circle extends Shape {
    // constructor not shown

    public void draw() {
        System.out.println("Drawing a ci...
Question 4
college-boardComputer Science AAPExam Style
1 mark

In a complex inheritance hierarchy where Class B extends Class A, and Class C extends B, which invocation within class C’s constructor will correctly call a non-default superclass constructor of A?

Question 5
college-boardComputer Science AAPExam Style
1 mark

What does 'super()' do when it appears as the first statement in a subclass's constructor?

Question 6
college-boardComputer Science AAPExam Style
1 mark

What is the difference between super() and super.method() in Java?

Question 7
college-boardComputer Science AAPExam Style
1 mark

If a method of a superclass is overridden in the subclass, which method is called by the line "methodName();" in the subclass?

Feedback stars icon

How are we doing?

Give us your feedback and let us know how we can improve

Question 8
college-boardComputer Science AAPExam Style
1 mark

What indicates the highest level of computational inefficiency when using the 'super' keyword within deeply nested inherited structures with complex algorithms?

Question 9
college-boardComputer Science AAPExam Style
1 mark

In a Java program, the "super" keyword can be used to do which of the following?

Question 10
college-boardComputer Science AAPExam Style
1 mark

Consider the code below. If we create an object of the Child class and call the printMessage() method on that object, what will happen?

java
class Parent {
    void printMessage() {
        System.out.println("Hello from Parent");
    }
}

class Child extends Parent {
    void printMessage() {
        ...