1/31
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
what is the difference between method overloading and method overriding in Java?
one means having the same method name but different parameters, while the other means a subclass changes a method that it inherits from its superclass
what is the purpose of the final keyword in Java?
means that a variable’s value, a method’s behaviour, and a class’ inheritance cannot be changed
what is the difference between a checked exception and an unchecked exception
one must be caught with try-catch or declared in the method, but the other happens during the program and don’t have to be handled explicitly
what is the difference between a constructor and a method in Java?
one initializes a new object, while the other performs actions on an object
what does the this keyword do in a constructor or method?
refers to the current instance of the class
what is the purpose of the super keyword in java?
refers to the superclass and is used to call parent class methods or constructors
explain the difference between == and equals() in Java
one checks if two objects are the exact same thing in memory, while the other checks if their contents or values are the same
what is the difference between a static method and a non-static method
one belongs to the class while the other belongs to an instance of the class
what is a final variable, and how is it different from a regular variable?
one cannot be changed once assigned, whereas a the other one can
how does the try-catch block work in exception handling?
one contains code that might throw an exception, and the other handles the exception if it occurs
what is the purpose of throw and throws keywords in Java exceptions?
one is used to cause an exception right away, while the other tells that a method might cause an exception
what is the difference between String and StringBuilder in Java?
one is immutable while the other is not
what is polymorphism and how is it used in Java?
it lets different kinds of objects be used like they are the same type, usually by replacing methods with new versions
what is an abstract class in Java?
is a class you can’t make objects from, but other classes can inherit from it
what is the difference between an interface and an abstract class in Java?
one is a list of method names without code that any class can use, and the other can have methods with or without code and other classes can extend it
what is a constructor overloading in Java?
occurs when multiple constructors with different parameters are defined in a class
what does instanceof operator do in Java?
checks if an object is of a certain type, it verifies the object’s class when the program is being ran
what is the purpose of the private access modifier in Java?
restricts access to a field or method to within the same class only
what is the null keyword in Java?
represents the absence of a value or reference for a variable
what is the purpose of the continue statement in Java?
skips the current iteration of a loop and moves to the next iteration
what is the difference between ArrayList and LinkedList?
one stores items in a growable array and lets you quickly get any item, while the other stores items in a chain and lets you add or remove items faster
what does the default keyword do in an interface?
lets a method in an interface have a default code that classes can use or override
what is method chaining?
lets you call methods one after another on the same object in one line, because each method returns the object itself
what is the difference between ArrayList and HashSet?
one lets you use store methods in an ordered list, because it keeps insertion order, while the other stores unique elements in no order because it does not allow duplicates
what is the purpose of the static keyword?
lets you use methods or variables without creating an object, because it belongs to the class itself
what is the difference between a method signature and a method declaration?
method signature includes the name and parameters, because it identifies the method while the method declaration includes the return type an access modifiers, because it defines the method
what is the purpose of the default constructor?
creates an object without setting any values because it is automatically provided if no constructor is given
what is the difference between Thread.sleep() and wait()?
one pauses the thread for a certain time, while the other pauses it until another is told to continue
what does super() do in a constructor?
calls the parent class constructor, because it ensures the parent class is properly set up
what is the purpose of the final keyword in method parameters?
lets you make sure a parameter’s value cannot be changed, prevents reassignment
what does the this keyword do in a constructor?
refers to the current object, because it helps distinguish instance variables from parameters
what is a hashcode?
uniquely identifies objects because it helps quickly locate and compare objects in hash-based collections