Ch 3 & 4 Quiz 3 Flashcards
T/F: in Java, a class can have one method with the same name, to avoid confusing the compiler.
F: A class May contain more than one constructor, or more than one method of the same name, as long as each has a distinctive set of parameter types.
What type can x be?
…
x someVariable;
x = “15.02”;
…
String
T/F: based on the code, you can conclude that type x is of a primitive type.
…
x someVariable;
x.doSomething();
…
F: the primitive types in Java are the non-object types. Types such as int, boolean, char, double, and long are the most common prim types. Prim types have no methods.
Breakpoint
A flag attached to a line of source code that will stop the execution of a method at that point when it is reached. It is represented in BlueJ editor as a small stop sign.
Classes that requires a second type to be specified as parameters are called?
Generic classes- in contrast to other classes do not define a single type in Java, but potentially many types.
Several objects are created in this code, which of them is considered an Anonymous object?
…
Public village()
{
smurf reader = new Smurf(); //#1
String name = new Smurf().getFirstName(); //#2
int age = new Smurf().getAge(); //#3
}
…
-2 & 3
-Anon object- object created with no name
- #1 has a variable that will point the created objects, so we can refer to this object later
- #2 & 3 has variables to remember the values returned from the methods called on the anon object. These 2 will only remember the values given to them, not the object that generated them.
Question 15
Practice question 15
Question 16
Work on question 16
Question 21
Practice question 21