NEW SWE Core 2 (Java) Flashcards

Fundamentals of Java: Data Types, Control Structures, Object-Oriented Programming, and JVM Basics

1
Q

What are the two main categories of data types in Java?

A

Primitive data types and reference data types.

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

True or False: In Java, the ‘int’ data type can hold decimal values.

A

False.

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

Fill in the blank: The _______ data type in Java is used to represent single characters.

A

char

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
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
5
Q

Which of the following is NOT a control structure in Java? A) if B) for C) class D) switch

A

C) class

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

Short Answer: What keyword is used to define a loop that will execute at least once?

A

do

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

True or False: Java supports multiple inheritance through classes.

A

False.

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

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

A

It refers to the current object instance.

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

Fill in the blank: A _______ in Java is a blueprint for creating objects.

A

class

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

Which of the following is a valid way to declare an array in Java? A) int[] arr; B) arr int[]; C) array int[];

A

A) int[] arr;

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

What is the main function of the Java Virtual Machine (JVM)?

A

To execute Java bytecode.

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

True or False: The JVM is platform-dependent.

A

False.

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

Short Answer: What is encapsulation in object-oriented programming?

A

The bundling of data and methods that operate on that data within a single unit or class.

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

What is the result of the expression ‘5 == 5’ in Java?

A

true.

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

Fill in the blank: In Java, a _______ can be used to define a method that does not return a value.

A

void

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

Which keyword is used to inherit a class in Java?

17
Q

True or False: An abstract class can be instantiated in Java.

18
Q

What is polymorphism in the context of object-oriented programming?

A

The ability of different classes to be treated as instances of the same class through a common interface.

19
Q

Fill in the blank: The _______ method is called when an object is created in Java.

A

constructor

20
Q

What does the ‘final’ keyword indicate when applied to a variable in Java?

A

The variable’s value cannot be changed once assigned.