NEW SWE Core 2 (Java) Flashcards
Fundamentals of Java: Data Types, Control Structures, Object-Oriented Programming, and JVM Basics
What are the two main categories of data types in Java?
Primitive data types and reference data types.
True or False: In Java, the ‘int’ data type can hold decimal values.
False.
Fill in the blank: The _______ data type in Java is used to represent single characters.
char
What is the default value of a boolean variable in Java?
false.
Which of the following is NOT a control structure in Java? A) if B) for C) class D) switch
C) class
Short Answer: What keyword is used to define a loop that will execute at least once?
do
True or False: Java supports multiple inheritance through classes.
False.
What is the purpose of the ‘this’ keyword in Java?
It refers to the current object instance.
Fill in the blank: A _______ in Java is a blueprint for creating objects.
class
Which of the following is a valid way to declare an array in Java? A) int[] arr; B) arr int[]; C) array int[];
A) int[] arr;
What is the main function of the Java Virtual Machine (JVM)?
To execute Java bytecode.
True or False: The JVM is platform-dependent.
False.
Short Answer: What is encapsulation in object-oriented programming?
The bundling of data and methods that operate on that data within a single unit or class.
What is the result of the expression ‘5 == 5’ in Java?
true.
Fill in the blank: In Java, a _______ can be used to define a method that does not return a value.
void
Which keyword is used to inherit a class in Java?
extends.
True or False: An abstract class can be instantiated in Java.
False.
What is polymorphism in the context of object-oriented programming?
The ability of different classes to be treated as instances of the same class through a common interface.
Fill in the blank: The _______ method is called when an object is created in Java.
constructor
What does the ‘final’ keyword indicate when applied to a variable in Java?
The variable’s value cannot be changed once assigned.