Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Which of the following is true about interfaces: An interface can have only non abstract methods. All methods in an interface must be abstract. A

Which of the following is true about interfaces:

An interface can have only non abstract methods.

All methods in an interface must be abstract.

A class can only implement one interface.

None of the items listed.

Can not contain constants but can have variables.

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

It must be in the parent class' constructor.

You cannot use super in a constructor.

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

Only one child class can use it.

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

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:

width, length, getPerimeter()

getPerimeter()

All of the items listed.

getArea()

width, length, getArea()

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 == p.x && y == p.y ); } 

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

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

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

public boolean equals(Point p) { System.out.println(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 (x, y);

this(0, 0);

x = a; y = b;

a = x; b = y; 

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

public double getX() { return x; } 

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

None of the items listed.

public double getX() { return a; } 

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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions