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
Q

What are the two ways that constructor methods are different from all other methods?

A
  1. Begins with an uppercase (because it’s named the same as the class)
  2. no return type is ever specified.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

How do we make an object if we don’t write a constructor method?

A

Java provides one to us, called the default constructor

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

What happens once we define our own constructor methods?

A

The default constructor is no longer available.

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

What is a static method?

A

A class method, means that an object does not need to be made to use the method.

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

What is an object method called?

A

Instance Method

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

What is special about a static variable?

A

It is visible to every method in a class. Every object made of that class has access to the SAME variable.

31
Q

Which visibility modifier is only accessible within the class?

A

Private

32
Q

Which visibility modifier is only accessible by classes in the same package, but NOT by sub-classes from other packages?

A

Default (no modifier)

33
Q

Which visibility modifier is accessible by classes in the same package AND child classes?

A

Protected

34
Q

Which visibility modifier is visible by anything?

A

Public

35
Q

What kind of method is used to return information about an object’s state?

A

Accessors or Getters

36
Q

What kind of method is used to change the value or state of an object?

A

Mutator or Setters

37
Q

What word is usually found in an accessor method’s name?

A

“get”

38
Q

What word is usually found in a mutator method’s name?

A

“set”

39
Q

What are 2 other names for the parent class?

A
  1. Base Class

2. Super Class

40
Q

Which pillar of OOP deals with the accessibility of methods and attributes from extended classes?

A

Inheritance

41
Q

How many super classes can a child class have?

A

1

42
Q

What kind of inheritance is Java?

A

Single Inheritance

43
Q

Which methods and attributes do sub-classes inherit from the super-class?

A

Any that are not declared as private

44
Q

What is meant by “inheritance is one way only”?

A

Sub-classes can inherit from the super-class, but the super-class gains nothing from the sub-classes.

45
Q

What is the mother of all classes?

A

The Object Class

46
Q

What part of the class hierarchy are abstract methods typically made?

A

Higher Up (super-class)

47
Q

What is missing with an abstract method?

A

Body code

48
Q

What must be included in a child class constructor?

A

A call to the superclass using the keyword “super”

49
Q

The first line in a sub-class constructor method?

A

Call to the super

50
Q

When does dynamic binding take place?

A

Runtime

51
Q

What is polymorphism?

A

The ability of the JVM to determine which version of an over-ridden method to run.

52
Q

What is another way to say dynamic binding?

A

Late binding

53
Q

What is the rule about visibility modifiers with regards to over-riding an abstract method in a sub-class?

A

Visibility modifier in the child class can be no more restrictive than in the base class

54
Q

Can a non-abstract class hold an abstract method?

A

No

55
Q

What does polymorphism apply to?

A

Only methods

56
Q

How must an object be instantiated to take advantage of polymorphism?

A

Referenced by a variable of the super class, and using the constructor of the sub class.

57
Q

Is an object of an abstract class able to be instantiated?

A

No

58
Q

Is an object of an abstract class ever created in memory?

A

Yes

59
Q

Can an object created using an abstract super variable use the methods from the sub-class?

A

No

60
Q

Can a sub-class be abstract if the base class is not?

A

Yes

61
Q

What are the 7 public methods all objects inherit from the object class?

A
  1. toString()
  2. equals()
  3. getClass()
  4. hashCode()
  5. notify()
  6. notifyAll()
  7. wait()
62
Q

What are the 2 protected methods inherited from the object class?

A
  1. finalize()

2. clone()

63
Q

What is special about data values in an interface?

A

They are constants by default

64
Q

What is an interface?

A

A type of class that provides abstract methods and constant values

65
Q

What are the 2 main uses of interfaces?

A
  1. Implementing a common function throughout a large number of classes
  2. Simulate multiple inheritance
66
Q

What keyword is used for classes using an interface?

A

Implements

67
Q

What is the keyword used when an interface’s method has body code?

A

default

68
Q

Can a static method in an interface be over-ridden?

A

No

69
Q

Can a default method in an interface be over-ridden?

A

Yes

70
Q

Can you instantiate an object from an interface?

A

No

71
Q

What is an interface with only one method?

A

A Functional Interface

72
Q

What is a difference in how an interface extends another interface?

A

Interfaces can extend multiple other interfaces, unlike classes which are single-parent.

73
Q

Can a class only implement 1 interface?

A

No, as many as it wants.