CSE 1321 Exam 3 Flashcards

1
Q

*Represent the concept of things in the real world (example: Dogs)

Follow the template:
- name
- variables (aka attributes)
- functions (aka methods, behaviors, method functions)

A

Classes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

These are what the object IS made up of

A

Variables relation to objects

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

These are what the object CAN DO

A

Functions relation to objects

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What would the smallest class look like?

A

class ClassName{
}

Notice that there is no MAIN here

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

*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

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

*Is an instance of a class
*has a state(variables) that is independent from others
EXAMPLE: your specific house with specific colors and finishes

A

Object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the purpose of a constructor

A

to initialize objects

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Can you have multiple constructors?

A

Yes; this is known as constructor overloading

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What happens if you don’t create a constructor

A

an “invisible” default constructor is made automatically. Otherwise you wouldn’t be able to create objects.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

When creating a constructor, the parameters should be only what we know (true/false)

A

true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

If an object’s state is constant, we should set it as a parameter of the constructor (true/false)

A

false

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

(Java) What is the purpose of using “this. “?

A

“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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Constructor names must match the name of the class they are in. (true/false)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is another word for SETTER?

A

Modifier or Mutator
(Note that the public and private keywords are known as ACCESS modifiers)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is another word for GETTER?

A

Accessor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the purpose of GETTERS and SETTERS?

A

They help with encapsulation which increases protection. By making variables private and creating GETTERS and SETTERS, you limit the ways in which someone can alter the private data.

17
Q

Is there a way to access private variables from outside a class?

A

Yes, if the private variables are in a class that also has non-private GETTER and SETTER methods for the private variables, you can access the variables from anywhere.

18
Q

When variables are private, where can you directly access them from?

A

Only the class they are inside will have access to the variable. Same goes for methods.

19
Q

When variables are public, where can you access them from?

A

Any class can refer to the variable. Same goes for methods.

20
Q

You can create multiple classes in one file. How many of these classes can be listed as PUBLIC?

A

Only one can be listed as public, and it has to match the file name.
All other classes will just be instantiated as class.

21
Q

can a SETTER method return more than one value?

A

SETTER methods don’t return value, they only set them, so the return type is VOID

22
Q

do SETTER methods need parameters?

A

Yes. The parameters will be whatever value you are setting. If you are setting the name of a dog to Sparky, your SETTER parameter will be a string.

23
Q

in the context of this class, do GETTER methods typically have parameters?

A

no. the purpose of the GETTER method is only to access a private value and return that value.

24
Q

An object’s method is called by

A

writing the objects name followed by the dot operator and the method name

25
Q

Object Oriented Programming is categorized by use of

A

classes and objects

26
Q

which keyword is reserved for creating objects?

A

new

27
Q

Strings are primitive data type that can use the + operation

A

false. strings are non-primative