BIG T's Flashcards

(17 cards)

1
Q

What’s Abstraction

A

The process of determining the set of data and methods that a class will have

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

What are two main parts of an object?

A

It’s properties and methods

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

What’s a class and object?

A

A class provides instructions for building an object.

The object is what gets built when the constructor method of the class file is called

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

What is Polymorphism?

A
You can have several methods with the same name defined in different classes of a class hierarchy.
This is called method overriding
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is an object?

A

A particular instance of a class

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

How is a constructor method different?

A
  • Always the same as the class name

- No return type specified

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

What does static mean?

A
  • Means we don’t have to instantiate an object of the class to use the method
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

A static variable is a class variable. What does this mean

A
  • Means it is visible to every method in the class
  • Just one copy of class variable in memory
  • If changed, all the objects will change
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How is an abstract method different?

A
  • There is no body code in an abstract method
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What’s the difference between method overloading and overriding?

A
  • Overloading: Same method name different parameters. Must be defined in the same class
  • Overriding: Same method name and signature. Must be used in seperate instances in the sub classes from a class heirarachy
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Can an abstract method be in a non abstract class

A

NO

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

Can an interface hold data values

A

Yes, But by default the values will be constants set as Public, Static and final
- Interfaces can only hold abstract methods

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

What changed in JDK 1.8?

A
  • Interfaces can now hold methods with default implementation and they can be declared static
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are the two main uses of interfaces?

A
  • Write an abstract method and have a large number of classes implement them
  • Multiple Inheritance Stimulation
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Can you instantiate and object from the interface?

A

NO, but the JVM can

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

What’s an abstract class and when is it created?

A
  • Whenever we create objects of the sub class, JVM will internally create an object of the abstract super class
17
Q

What must be done for Polymorphism to work?

A

The objects of the subclasses have to be created and referenced by a variable of the superclass