Home
Flashcards
Preview
Java MT 5
Home
Get App
Take Quiz
Create
What is a constructor?
used to perform operations at the time an object is created.
public Rectangle(double len, double w)
{
length = len;
width = w;
}
Constructors have the same name as the _______
class
Constructors have no ___________
return type
A constructor that doesn't accept arguments is a ______________
no-arg constructor.
What does a no-arg constructor look like?
public Rectangle(){
length = 0.0;
width = 0.0;
}
What is method overloading?
Two or more methods in a class have the same name.
public int add(int num1, int num2)
public String add (String str1, String str2)
A __________ consists of the method’s name and the data types
method signature
add(int, int)
The process of matching a method call with the correct method is known as ________ .
binding
What is Shadowing
Method with a local variable with the same name as an Instance Field.
What does the toString method do?
returns the class name and a hash of the memory address of the object.
the _________ method is usually called implicitly when passing to _________ or concatenating.
toString
println
when the == operator is called, the __________ are compared.
memory addresses.
How is the == method overridden?
public boolean equals(Stock object2) {
boolean status;
if(symbol.equals(Object2.symbol)
&& sharePrice == Object2.sharePrice)
status = true;
else
status = false;
return status;
}
The purpose of overriding the == method is to ___________
Compare by contents rater than addresses.
Author
gianni11
ID
207419
Card Set
Java MT 5
Description
MT 5 pp9 & 10
Updated
2013-03-16T05:41:01Z
Show Answers
Home
Flashcards
Preview