What does it mean if a method is said to override another method in Java?
It means that a subclass provides a specific implementation for a method that is already defined in its superclass.
2
New cards
What is method overloading in Java?
Method overloading occurs when two or more methods in the same class have the same name but different parameters (type, number, or both).
3
New cards
What does it mean to hide a method in Java?
Hiding a method occurs when a static method in a subclass has the same name and parameters as a static method in the superclass, effectively hiding the superclass's version.
4
New cards
What does the `toString()` method do in Java?
The `toString()` method returns a string representation of an object.
5
New cards
What is an abstract class in Java?
An abstract class is a class that cannot be instantiated and may contain abstract methods that must be implemented by subclasses.
6
New cards
What is a checked exception in Java?
A checked exception is an exception that is checked at compile-time, and the programmer is required to handle it, typically using try-catch blocks.
7
New cards
What is a HashMap in Java?
HashMap is a part of Java's collection framework, implementing the Map interface, and is used for storing key-value pairs.
8
New cards
What is a Collection in Java?
Collection is a root interface in the Java collection framework, representing a group of objects.
9
New cards
What does the `public` access modifier mean in Java?
The `public` access modifier allows the class, method, or variable to be accessible from any other class.
10
New cards
What is the output of comparing two String objects using `==`?
The `==` operator checks for reference equality, meaning it checks if both references point to the same object.
11
New cards
What does `void` mean in a method signature?
The `void` keyword indicates that the method does not return any value.
12
New cards
What is a `Map` in Java?
A `Map` is an object that maps keys to values, allowing for retrieval with keys.
13
New cards
What is the purpose of the `main` method in Java?
The `main` method is the entry point of any Java application, where the program execution begins.
14
New cards
What are generics in Java?
Generics enable types (classes and interfaces) to be parameters when defining classes, interfaces, and methods, allowing for type safety.
15
New cards
What does it mean to implement an interface in Java?
Implementing an interface means a class agrees to perform the behavior defined by the methods of the interface.
16
New cards
What is the purpose of the `final` keyword in Java?
The `final` keyword signifies that a variable cannot be reassigned, a method cannot be overridden, or a class cannot be inherited.
17
New cards
What does `System.out.println` do in Java?
`System.out.println` is used to print a message to the console, followed by a new line.
18
New cards
What does `this` keyword refer to in Java?
The `this` keyword refers to the current object instance.
19
New cards
What is polymorphism in Java?
Polymorphism is a concept where a method or a function behaves differently based on the object that it is acting upon.
20
New cards
What does the `protected` access modifier do in Java?
The `protected` modifier allows access to a class's members by classes in the same package and subclasses.