Chapter 5 Flashcards
___ in a program can represent real-world things or abstractions
Objects
An _____ of a class is an object
instance
True or False, The class definition has no data—that is, no numbers and no string. The individual objects have the data, but the class specifies what kind of data they have. The class also specifies what actions the objects can take and how they accomplish those actions.
True
the data items and the methods are sometimes called ___ because they belong to the object
members
What are these called?
public String name;
public String breed;
public int age;
Instance Variables
Why do we need the word new ?
we use to create objects of a class.
What is nextInt is?
a method
Methods that some preform action other than returning a value are called
void methods
What is the formula to call a method?
You invoke a method by writing the name of the receiving object followed by a dot, the name of the method, and finally a set of parentheses that can contain arguments providing information for the method. Object.Method( );
What is a Scanner?
Class
True or False, Is it true that main is a void method?
true
True or False. It is preferred to use one return statement in a method.
True
Does Java have functions?
No, it doesnt
Can a void method contain a return statement?
Since a void method returns no value, it typically does not have any return statement. However, you can write a return statement within a void method without an accompanying expression, as follows:
return;
True or False, within a class definition, this is a name for the receiving object
True
What is “ this “ can be used for?
you can use the keyword this as a name for the object receiving the method call
Variables are confined to a method definition
local variables
Variables are confined to an object of a class
instance variables
A type of variables that Java does not have, but other programmes have
global variables.
When you declare a variable within a compound statement, the compound statement is usually called
block
The things that serve as blanks in methods are called
parameters
Java passes arguments to a method using
call-by-value
True or False, In Java, you can choose the name of a method’s formal parameter without any concern that this name will be the same as an identifier used in some other method. Formal parameters are really local variables, and so their meanings are confined to their respective method definitions.
True
True or False. An argument in a method invocation that is of any of these types will automatically be converted to any of the types that appear to its right if that is needed to match a formal parameter:
byte→short→int→long→float→double
True