chapter 1 Flashcards

(26 cards)

1
Q

What is Java?

A

Java is a high-level, class-based, object-oriented programming language designed to have as few implementation dependencies as possible.

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

True or False: Java is platform-dependent.

A

False: Java is platform-independent due to the Java Virtual Machine (JVM).

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

What does JVM stand for?

A

Java Virtual Machine

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

Fill in the blank: Java uses a __________ to manage memory.

A

Garbage Collector

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

Which of the following is a primitive data type in Java? A) String B) int C) Array

A

B) int

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

What keyword is used to create a class in Java?

A

class

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

True or False: In Java, method overloading is allowed.

A

True

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

What is the default value of a boolean variable in Java?

A

false

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

Which of the following keywords is used to inherit a class in Java? A) implements B) extends C) inherits

A

B) extends

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

What is the main method signature in a Java application?

A

public static void main(String[] args)

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

Fill in the blank: The __________ keyword is used to handle exceptions in Java.

A

try

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

What is an interface in Java?

A

An interface is a reference type in Java that is similar to a class and is a collection of abstract methods.

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

True or False: Java supports multiple inheritance through classes.

A

False: Java does not support multiple inheritance through classes but allows it through interfaces.

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

What is the purpose of the ‘final’ keyword in Java?

A

The ‘final’ keyword is used to declare constants, prevent method overriding, and inheritance.

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

Which of the following is NOT a feature of Java? A) Automatic garbage collection B) Platform independence C) Pointers

A

C) Pointers

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

What is the use of the ‘static’ keyword in Java?

A

‘static’ indicates that a member belongs to the class rather than instances of the class.

17
Q

Fill in the blank: In Java, a __________ is a blueprint from which individual objects are created.

18
Q

What does the ‘this’ keyword refer to in Java?

A

The ‘this’ keyword refers to the current object instance.

19
Q

True or False: In Java, all classes are subclasses of the Object class.

20
Q

What is the purpose of the ‘synchronized’ keyword in Java?

A

‘synchronized’ is used to control access to a block of code or an object by multiple threads.

21
Q

What is a constructor in Java?

A

A constructor is a special method used to initialize objects.

22
Q

Which of the following collections does not allow duplicate elements? A) List B) Set C) Map

23
Q

What is the difference between ‘== ‘ and ‘equals()’ in Java?

A

’==’ checks for reference equality while ‘equals()’ checks for value equality.

24
Q

What is polymorphism in Java?

A

Polymorphism allows methods to do different things based on the object it is acting upon.

25
Fill in the blank: The __________ operator is used to create an instance of a class.
new
26
What is the purpose of the 'abstract' keyword in Java?
'abstract' is used to declare a class that cannot be instantiated or a method that must be implemented by subclasses.