Quiz #1 Flashcards

1
Q

Definition: Determining the set of features (properties and methods) that a class will have.

A

Abstraction

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

What are the two main properties of an object?

A
  1. Properties (data/variables)

2. Methods

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

Everything in Java is an object, except:

A

Primitive data types

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

Definition: The collection of code that contains the instructions for building an object.

A

Class

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

What are the three pillars of object oriented programming?

A
  1. Encapsulation
  2. Inheritance
  3. Polymorphism
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Which concept of OOP deals with visibility modifiers and access to data and methods of a class?

A

Encapsulation

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

Basic idea of encapsulation:

A

Being able to control access to an object’s properties and methods

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

Which concept of OOP deals with the extension of classes?

A

Inheritance

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

Basic idea of inheritance:

A

A sub-class (child class) can inherit methods from its super class (parent class)

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

Every class in Java inherits methods and properties from what class?

A

Object Class

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

Which concept of OOP deals with method over-riding?

A

Polymorphism

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

What are two other ways to say polymorphism?

A
  1. Late binding

2. Dynamic binding

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

What is the difference between method overloading and method over-riding?

A

Method over-riding involves creating methods of the same name in DIFFERENT classes of the same hierarchy.

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

What is like a blueprint, or recipe in OOP?

A

Classes

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

What is an instance of a class?

A

An Object

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

What is an object?

A

A named instance of a class held in memory, consisting of methods and properties.

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

What is the state of an object?

A

The values held in it’s data variables

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

What is known as an object’s behaviour?

A

It’s Methods.

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

What does UML stand for?

A

Unified Modeling Language

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

UML: What does an italicized name mean?

A

Abstract

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

UML: What do the +, -, and # mean

A

+ == public
- == private
# == protected

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

UML: What does an underline mean?

A

Static

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

If you don’t specify an access modifier, what visibility does it have?

A

Default visibility: Only classes in the same package can view it.

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

What is a constructor method?

A

A constructor method is the method used to instantiate an object in memory.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What are the two ways that constructor methods are different from all other methods?
1. Begins with an uppercase (because it's named the same as the class) 2. no return type is ever specified.
26
How do we make an object if we don't write a constructor method?
Java provides one to us, called the default constructor
27
What happens once we define our own constructor methods?
The default constructor is no longer available.
28
What is a static method?
A class method, means that an object does not need to be made to use the method.
29
What is an object method called?
Instance Method
30
What is special about a static variable?
It is visible to every method in a class. Every object made of that class has access to the SAME variable.
31
Which visibility modifier is only accessible within the class?
Private
32
Which visibility modifier is only accessible by classes in the same package, but NOT by sub-classes from other packages?
Default (no modifier)
33
Which visibility modifier is accessible by classes in the same package AND child classes?
Protected
34
Which visibility modifier is visible by anything?
Public
35
What kind of method is used to return information about an object's state?
Accessors or Getters
36
What kind of method is used to change the value or state of an object?
Mutator or Setters
37
What word is usually found in an accessor method's name?
"get"
38
What word is usually found in a mutator method's name?
"set"
39
What are 2 other names for the parent class?
1. Base Class | 2. Super Class
40
Which pillar of OOP deals with the accessibility of methods and attributes from extended classes?
Inheritance
41
How many super classes can a child class have?
1
42
What kind of inheritance is Java?
Single Inheritance
43
Which methods and attributes do sub-classes inherit from the super-class?
Any that are not declared as private
44
What is meant by "inheritance is one way only"?
Sub-classes can inherit from the super-class, but the super-class gains nothing from the sub-classes.
45
What is the mother of all classes?
The Object Class
46
What part of the class hierarchy are abstract methods typically made?
Higher Up (super-class)
47
What is missing with an abstract method?
Body code
48
What must be included in a child class constructor?
A call to the superclass using the keyword "super"
49
The first line in a sub-class constructor method?
Call to the super
50
When does dynamic binding take place?
Runtime
51
What is polymorphism?
The ability of the JVM to determine which version of an over-ridden method to run.
52
What is another way to say dynamic binding?
Late binding
53
What is the rule about visibility modifiers with regards to over-riding an abstract method in a sub-class?
Visibility modifier in the child class can be no more restrictive than in the base class
54
Can a non-abstract class hold an abstract method?
No
55
What does polymorphism apply to?
Only methods
56
How must an object be instantiated to take advantage of polymorphism?
Referenced by a variable of the super class, and using the constructor of the sub class.
57
Is an object of an abstract class able to be instantiated?
No
58
Is an object of an abstract class ever created in memory?
Yes
59
Can an object created using an abstract super variable use the methods from the sub-class?
No
60
Can a sub-class be abstract if the base class is not?
Yes
61
What are the 7 public methods all objects inherit from the object class?
1. toString() 2. equals() 3. getClass() 4. hashCode() 5. notify() 6. notifyAll() 7. wait()
62
What are the 2 protected methods inherited from the object class?
1. finalize() | 2. clone()
63
What is special about data values in an interface?
They are constants by default
64
What is an interface?
A type of class that provides abstract methods and constant values
65
What are the 2 main uses of interfaces?
1. Implementing a common function throughout a large number of classes 2. Simulate multiple inheritance
66
What keyword is used for classes using an interface?
Implements
67
What is the keyword used when an interface's method has body code?
default
68
Can a static method in an interface be over-ridden?
No
69
Can a default method in an interface be over-ridden?
Yes
70
Can you instantiate an object from an interface?
No
71
What is an interface with only one method?
A Functional Interface
72
What is a difference in how an interface extends another interface?
Interfaces can extend multiple other interfaces, unlike classes which are single-parent.
73
Can a class only implement 1 interface?
No, as many as it wants.