Methods & classes Flashcards
What do you call an entity in your program that you can change/manipulate?
Object
What other term can you call an Object?
Method
System.out
Object
How can you manipulate the System.out object?
Using println method
Is println a method?
yes
What else do we think of an object as?
a black box
Does an object have a public interface?
yes
What is a public interface
methods that you call
What does an implementation do?
Uses code and data to make methods work
Different or similar: System.out and “Hello, World!” Why?
different, because they are different classes
What class supports a number of methods?
String class
How do you construct any object?
- use the NEW operator
- give the name of the CLASS
- supply construction PARAMETERS with parenthesis
variable
item of information in memory
cerealBox
variable
How do you initialize the variable Rectangle cerealBox;?
Use the new operator which will create an object and return its location
What is an object location called?
object reference
What does an access specifier do?
controls which other methods can call this method
Should most methods be declared as Public?
Yes
What statement terminates a method?
return ();
What are instance fields generally declared as?
private
What happens if the instance fields are declared as private?
all date access must run through the Public Methods
What does an instance field belong to?
A class
What does the constructor always have the same as?
class of the objects it constructs
What do constructors NOT have?
return types
What do constructors and methods form?
Public interface
What happens when the same name is used for more than one method/constructor?
Overloaded
What do local and parameter variables belong to?
Methods
What is the difference between local and instance vairables?
Initialization
What are instance fields initialized with if there is no constructor?
a default value
An object is a “black box” with a public BLANK and a hidden BLANK.
interface, implementation
An object stores its state in one or more variables called…
Instance fields
true or false: instance fields are initialized to a default value
true
true or false: java initializes local variables to a default value
false
What does it mean for a constructor or method to be overloaded?
same name but different parameters
What is the lifetime of a local variable?
within the method or constructor
System is a:
class
out is an:
object
println is a:
method
Public Unicorn is a :
class
Unicorn connect = new Unicorn(); is a :
object
public void getName() is a :
method
What is NUM_SIDES?
a constant