Question: What is the rule for a super reference in a constructor? It must be in the parent class' constructor. It must be the last line

What is the rule for a super reference in a constructor?

It must be in the parent class' constructor.

It must be the last line of the constructor in the child class.

It must be the first line of the constructor in the child class.

Only one child class can use it.

You cannot use super in a constructor.

Consider the following class definition.

public class WhatsIt { private int length; private int width; public int getArea () { // implementation not shown } private int getPerimeter () { // implementation not shown } }

A child class Thingy that extends WhatsIt would have access to:

getArea()

getPerimeter()

width, length, getPerimeter()

width, length, getArea()

all of the above

Questions 18 - 20 pertain to the following class, Point:

public class Point { private double x; private double y; public Point() { this (0, 0); } public Point(double a, double b) { /* missing code */ } // ... other methods not shown }

Which of the following correctly implements the equals method?

public boolean equals(Point p) { return (x == Point.x && y == Point.y); }

public void equals(Point p) { System.out.println(x == p.x && y == p.y); }

public boolean equals(Point p) { System.out.println(x == p.x && y == p.y); }

public boolean equals(Point p) { return (x == p.x && y == p.y ); }

public void equals(Point p) { return (x == p.x && y == p.y ); }

The default constructor sets x and y to (0, 0) by calling the second constructor. What could be used to replace /* missing code */ so that this works as intended?

a = 0; b = 0;

this(0, 0);

this (x, y);

a = x; b = y;

x = a; y = b;

Which of the following correctly implements a mutator method for Point?

public double getX() { return x; }

public double getX() { return a; }

public void setCoordinates (double a, double b) { x = a; y = b; }

public void setCoordinates (double a, double b) { Point p = new Point(a,b); }

None of the above

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!