what is the equals and hashCode contract?
If two object are equal according to the equals method then calling the hashcode method on each of the two objects must produce the same integer result.
What is the goal of the Singleton Pattern?
The goal of the singleton pattern is to make sure that only one instance of the class is created.
How to achieve the singleton pattern?
To achieve the singleton pattern, you need to do three things:
How can you aggregate features of another class?
To aggregate features of another class, you either extend that class(Inheritance) of have an object of the other class in your class(Composition).
Wich exceptions can an overriding method trow?
An overriding method can only throw either the checked exceptions(and subclasses) listed in the throw clause of the overridden method or decide not to throw any exceptions at all.
Are unchecked exceptions required to be listed in the throw clause?
Unchecked exceptions (Runtime exceptions) are not required to be listed in a throw clause, thus any method can declare any unchecked exceptions in its throw clause
What will the hashcode method in object return?
The default HashCode method in object will return a different hashcode for each object.
Can you override a final method?
You can not override a final method
How are fields in an interface defined?
All fields defined in an interface are implicitly public, static final
How are methods in an interface defined?
Interface methods do not have a body and are by default abstract and public
can a overriding method make the overridden method more private?
An overriding method cannot make the overridden method more private. It can make the method more public though
How to make a class immutable?
What are default methods in an interface?
Default methods are declared with the default keyword and are implicitly public. and they provide an implementation
Can you change the acces modifier when overloading a method?
When overloading a method, you are free to make it private, default, protected or public
what is method overloading?
With method overloading, multiple methods can have the same name with different parameters.