Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

QUESTION 1 In OOP, a parent class is also called a 1. base class 2. superclass 3

ID: 3604403 • Letter: Q

Question

QUESTION 1

In OOP, a parent class is also called a

                       

1. base class              

2. superclass  

3. derived class          

4. ruling class

5. subclass

QUESTION 2

Which of the following statements about representing inheritance relationship between two classes in a UML class diagram are true?

1. Draw an arrow from the child class to the parent class.

2. The arrowhead can be any type, e.g, -->, solid triangle.            

3. Draw an arrow from the parent class to the child class.             

4. The arrowhead must be a hollow triangle.

QUESTION 3

Below is a class declaration:

public class JFrame extends Frame

Based on the declaration, we know the subclass is ____, the superclass is ______.

QUESTION 4

Given the following class declaration:

public class JFrame extends Frame

and given that each class appearing in the above declaration has a one-argument constructor that has a String argument; and given that JFrame's constructor calls Frame's constructor.

Which of the following code implements the JFrame's constructor correctly?

  

1.public JFrame(String title) {

this(title);

}

                       

2. public JFrame(String title) {

Frame(title);

}

3. public JFrame(String title) {

super.Frame(title);

}

                       

4. public JFrame(String title) {

super(title);

}

QUESTION 5

Given the following class declaration

public class JFrame extends Frame

Each of the class in the declaration has a constructor with a String type argument.

Among the following statements, indicate the ones that correctly use the class or classes appearing in the above declaration.

                       

1. String window = new JFrame("Tax Calculator");

2. JFrame window = new Frame("Tax Calculator");

3. JFrame window = new JFrame("Tax Calculator");                       

4. Frame window = new JFrame("Tax Calculator");

QUESTION 6

Suppose that the Student class has a name attribute with private visibility. Its 1-argument constructor and the getter and the setter for the attribute have public visibility.

Suppose the Graduate class is declared like the following:

public class Graduate extends Student

The Graduate students also has a degreeProgram attribute. Indicate which of the following statements are correct.

1. You must implement a getter method for the name attribute in the Graduate class.

2. The setter method for the name attribute is inherited by the Graduate class.

3. A Graduate instance has only one attribute: degreeProgram                  

4. A Graduate instance has two attributes: name and degreeProgram

Explanation / Answer

Question 1.

1. base class 2. superclass

In object oriented programming a parent class is called base class or super class which the other classes can be derived from these class.

Question 2.

1. Draw an arrow from the child class to the parent class.

In class diagrams we call it as generalisation which is equalent to inheritence it is shown as a solid line with closed arrow head from sub class to parent class.

Question 3:-

Based on the declaration, we know the subclass is JFrame, the superclass is Frame.

Question 4:-

4. public JFrame(String title) {

super(title);

}

Super is the keyword which we use to access the parent class.

Question 5:-

2. JFrame window = new Frame("Tax Calculator");

3. JFrame window = new JFrame("Tax Calculator");

Because derived class extends from the base class. It has also access to base class so derived class.

Question 6:-

4. A Graduate instance has two attributes: name and degreeProgram

Using the getter method of the base class derived class can inherit the private data member in the base class. So in this way It has two attributes name and degreeProgram.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote