All Flashcards
How are arrays applied in real-world scenarios?
Storing lists of data, such as student names, product prices, or sensor readings.
How are ArrayLists applied in real-world scenarios?
Managing a dynamic list of items, such as a shopping cart or a playlist.
How are 2D arrays applied in real-world scenarios?
Representing tables of data, such as spreadsheets, game boards, or image pixels.
How is inheritance applied in real-world scenarios?
Creating a hierarchy of classes, such as different types of vehicles inheriting from a base Vehicle class.
How is recursion applied in real-world scenarios?
Solving problems that can be broken down into smaller, self-similar subproblems, such as searching a file system or parsing a complex data structure.
How are if statements applied in real-world scenarios?
Controlling program flow based on conditions, such as validating user input or determining which action to take based on the current state.
How are for loops applied in real-world scenarios?
Iterating through a collection of data, such as processing each item in a list or performing an action a specific number of times.
How are while loops applied in real-world scenarios?
Repeating an action until a certain condition is met, such as continuously reading data from a sensor until a specific value is reached.
What is operator precedence?
The order in which operations are performed (PEMDAS).
What is the purpose of if statements?
To execute code blocks based on conditions.
What is the purpose of for loops?
To repeat code a specific number of times.
What is the purpose of while loops?
To repeat code while a condition is true.
What is the difference between = and ==?
= is the assignment operator, while == is the equality check operator.
Why are Strings immutable?
Strings are immutable to improve efficiency and security. Once created, their value cannot be changed.
What is the purpose of instance variables?
Instance variables store the data associated with each object.
What is encapsulation?
Bundling data (instance variables) and methods that operate on the data into a single unit (class), hiding the internal state of an object.
Why use the this keyword?
To refer to the current object and distinguish between instance variables and parameters with the same name.
Why are array sizes fixed?
For memory efficiency and predictable access times.
What is the purpose of the super keyword?
Used to call the constructor or methods of the superclass.
What is method overriding?
A subclass providing its own implementation of a method already defined in the superclass.
What is a base case in recursion?
The condition that stops the recursive calls and provides a direct solution.
What is a recursive step in recursion?
The part of the recursive method where the method calls itself with a modified input, moving closer to the base case.
What is an int?
A primitive data type representing whole numbers.
What is a double?
A primitive data type representing decimal numbers.
What is a boolean?
A primitive data type representing true or false values.
What is modulo?
An arithmetic operator (%) that returns the remainder of a division.
What is a compound assignment operator?
An operator that combines an arithmetic operation and assignment (e.g., +=, -=).
What is post-increment?
An operator (x++) that returns the original value of x, then increments it.
What is pre-increment?
An operator (++x) that increments x, then returns the new value.
What is short-circuit evaluation?
The process where the second condition in AND/OR operations isn't evaluated if the result is already known.
What is a String?
A sequence of characters, immutable in Java.
What is a class?
A blueprint for creating objects, containing data (fields) and behavior (methods).
What is an object?
An instance of a class, created using the new keyword.
What is a constructor?
A special method used to initialize objects, having the same name as the class.
What is an array?
An ordered collection of elements of the same type with a fixed size.
What is an ArrayList?
A dynamic, resizable array in Java.
What is inheritance?
A mechanism where a class (subclass) inherits properties and methods from another class (superclass).
What is polymorphism?
The ability of an object to take on many forms, achieved through inheritance and method overriding.
What is recursion?
A method that calls itself, requiring a base case to stop the recursion.