CSE 1321 Exam 3 Flashcards
*Represent the concept of things in the real world (example: Dogs)
Follow the template:
- name
- variables (aka attributes)
- functions (aka methods, behaviors, method functions)
Classes
These are what the object IS made up of
Variables relation to objects
These are what the object CAN DO
Functions relation to objects
What would the smallest class look like?
class ClassName{
}
Notice that there is no MAIN here
*Has attributes
*Has a constructor whish is used to intialize attributes
*Has other methods
*Template for creating objects
*Creates a new complex data type
EXAMPLE: blueprints for a house
Class
*A class is basically just you creating a data type and it doesn’t need to run any code unless you tell it to.
*Is an instance of a class
*has a state(variables) that is independent from others
EXAMPLE: your specific house with specific colors and finishes
Object
What is the purpose of a constructor
to initialize objects
Can you have multiple constructors?
Yes; this is known as constructor overloading
What happens if you don’t create a constructor
an “invisible” default constructor is made automatically. Otherwise you wouldn’t be able to create objects.
When creating a constructor, the parameters should be only what we know (true/false)
true
If an object’s state is constant, we should set it as a parameter of the constructor (true/false)
false
(Java) What is the purpose of using “this. “?
“this. “ tells the program that the variable after the dot operator is a variable inside that class. It is used commonly with constructors and methods.
Constructor names must match the name of the class they are in. (true/false)
True
What is another word for SETTER?
Modifier or Mutator
(Note that the public and private keywords are known as ACCESS modifiers)
What is another word for GETTER?
Accessor