Object Oriented Flashcards

(18 cards)

1
Q

Methods that operate on the fields of a class are known as

A

Instance Methods

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

What are methods called that are not ‘instance methods’

A

Class methods or static methods

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

What can you not do with an abstract class

A

Cannot instantiate it

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

In an abstract class what are abstract methods

A

methods that subclasses must implement

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

When both the superclass and the subclass define constructors, the process is complicated because __________________ In this case, you must use another of Java’s keywords ________

A
  1. both the superclass and the subclass constructors must be executed.
  2. Super
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

The Java keyword super has two general forms

A
The first calls a superclass constructor
The second is used to access a member of the superclass that has been hidden by a member of a subclass
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

If you wish to access a superclass constructor super must ________

A

Always be the first statement executed inside a subclass constructor

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

How do you invoke a method or an instance variable of a parent class

A

super.member

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

When would you use super.member

A

when the method/variable names of a subclass hide the method/variable names of the parent class

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

When a subclass object is created whose constructor is executed first? Is it the parent class or the subclass?

A

It follows derivation. The parent class first

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

What are two ways of creating a method that must be overridden

A

Create a method that throws an exception or prints “Must override” to the screen
Use the Abstract modifier

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

What keyword prevents someone from overriding a method?

A

final

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

What does declaring a method parameter to be ‘final’ do?

A

prevents the variable from being changed in the method

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

What does declaring a variable in a method to be final do

A

prevents it from being assigned a value more than once

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

What is the difference between the private and the protected access modifier

A
A private member is accessible only to other members of its class.
A protected class is accessible only to other members of its package
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How is Java’s protected different from that of C++

A

In C++ protected means only accessible from subclasses

17
Q

One interface can extend another interface by use of the word

18
Q

Prior to JDK 8 an interface could not define any implementation whatsoever. What has changed?

A

JDK 8 has added a new capability to interface called default method