Final review: ch5--> Flashcards Preview

Java 1 > Final review: ch5--> > Flashcards

Flashcards in Final review: ch5--> Deck (12)
Loading flashcards...

what are Objects? thought of as what by programmers?

the creation of a blueprint once built. programmers view them as programs. (The steering wheel of a car but not the inner workings or variables).


what is a class? how is it used?

class is the blueprint of a program (object). data and methods are grouped in a class to create objects.
**Classes are called on to create objects.


give an example of what a method within a class would look like (what the class looks like) and then show how that class can be called on to create a new object:
--Class is cars
-- create parameters for a setter (user enters car type)
++list line of object code in a program calling on the created class where a user enters their car type.

class cars
public void setCarType (String carType);

++the program(object) of code below:
cars myCar = new cars();
public void myCar.setCarType(" Honda");

The --myCars-- is a new object that is created
"Honda" is the car type that is set in the object program but the class method predefined in the class program makes sure that a string is entered here.


what methods make up a class (list several)?

setters, getters, constructors, string method, mutators
also known as (access modifier, return type, name, arguments and method statements


where is the main method used in java? the creation of the class or the creation of the driver/ program?

the driver and program only use the main method so if you see it then you are looking at the application and not the creation of a class. *The program does not start until the main method. Main method is always used with public static void main (String{} Args);


how many objects of the same class can be created?

as many as you want. The objects are like the cars in a car lot if the carLot is the class.


how does one invoke a method on an object in an application?

the "." period operator is used.
objectIsHere.MethodInvokedOnObject(data Entered here gets assigned to the class variable that is in the class file);


what 2 steps are there to create an object from a class?

1-choosing and declaring a variable for the new object
2-assigning the variable with explicitly allocated instance of the class type
2--- class types are int, double, string, char, etc.


what is the member access operator and what does it do?

used in a programs code.
member access operator is a period . that is placed between an object and a method. It allos the method to act on the object.
ex: myCar.setRating(4); This sets the rating of my car and assigns 4 to a variable inside the myCar class where it can be added to other methods inside the class like the toString method and when i call on that method in my program then that data (4) can be printed if desired. **the data entered does stuff in the background.


difference between variables and objects:

objects are made from a class and use the class name to instantiate a new object.
variable uses a data type such as int before a chosen name. it is not a creation from a class.
className objectNamechosen = new className();
int variableName;


how do i name an object after it has been instantiated from a class? type out code

objectName.setName("name chosen");
^Remember this is used inside an application (public) and not inside the class. the class holds the blueprints so that setName method works when called on and the data type String is defined in the class method.


how to make it so that the print() method displays a certain string or set of data when called on in an application?

in the class (when creating the class) set up these parameters using variables that have been set in other methods/ constructors within the class code. (The application should interact with these other methods so that correct data is assigned to these hidden variables).
ex inside the class:
public void print( variableOne + " " + variable2);
when the print method is called on then whatever is held in the two variables will display to the user in its program.
objectMyCarType.print( );