Java review

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/25

encourage image

There's no tags or description

Looks like no tags are added yet.

26 Terms

1
New cards

What does extends mean in Java?

A class inherits properties and methods from another class.

2
New cards

What does implements mean in Java?

A class agrees to implement the methods required by an interface.

3
New cards

Can a Java class extend multiple classes?

No. A class can extend only one class.

4
New cards

Can a Java class implement multiple interfaces?

Yes.

5
New cards

Which keyword is used with a parent class?

extends

6
New cards

Which keyword is used with an interface?

implements.

7
New cards

What happens if a class implements an interface but does not implement all its required abstract methods?

The class must be declared abstract.

8
New cards

abstract method

A method declared without a body.

9
New cards

A class can implement…

A class can implement multiple interfaces.

10
New cards

How many classes can be extended by another class

A class can extend only one class.

11
New cards

What is polymorphism in Java?

The ability of one thing to take many forms.

12
New cards

What does polymorphism allow?

Different objects to respond to the same method call in different ways.

13
New cards

What are the two main types of polymorphism?

Compile-time and runtime polymorphism.

14
New cards

What is a superclass?

The parent class being inherited from.

15
New cards

What is a subclass?

A child class that inherits from another class

16
New cards

What are generics in Java?

A feature that allows classes and methods to work with different data types.

17
New cards

Why do programmers use generics?

To improve type safety and reduce casting

18
New cards

What symbol is used to represent a generic type parameter?

Angle brackets < >.

19
New cards

What does T commonly represent in generics?

Type. It is a placeholder for a data type.

20
New cards

What does E commonly represent in generics?

Element, often used when working with collections.

21
New cards

What is a generic class?

A class that can work with different data types.

22
New cards

How do you declare a generic class?

class Box<T> { }

23
New cards

What does Box<Integer> mean?

A Box object that stores Integer values.

24
New cards

What is type safety?

Making sure the correct data types are used.

25
New cards

What happens if you try to add the wrong type to a generic collection?

Java produces a compile-time error.

26
New cards

What does <T> mean in a generic method?

The method can accept a value of a specified type.