What are some alternatives to inheritance?
Delegation is an alternative to inheritance. Delegation means that you include an instance of another class as an instance variable, and forward messages to the... Read more »
Delegation is an alternative to inheritance. Delegation means that you include an instance of another class as an instance variable, and forward messages to the... Read more »
Yes even if you write return as the last statement in the try block and no exception occurs, the finally block will execute. The finally block will execute and then... Read more »
It is not necessary that each try block must be followed by a catch block. It should be followed by either a catch block OR a finally block. And whatever exceptions... Read more »
There are two ways to handle exceptions, 1. By wrapping the desired code in a try block followed by a catch block to catch the exceptions. and 2. List the desired... Read more »
An unhandled exception moves up the method stack in search of a matching When an exception is thrown from a code which is wrapped in a try block followed by one... Read more »
An error is an irrecoverable condition occurring at runtime. Such as OutOfMemory error. These JVM errors and you can not repair them at runtime. While exceptions... Read more »
Runtime exceptions are those exceptions that are thrown at runtime because of either wrong input data or because of wrong business logic etc. These are not checked... Read more »
Checked exception are those which the Java compiler forces you to catch. e.g. IOException are checked Exceptions. Read more »
No there is not sizeof operator in Java. So there is not direct way to determine the size of an object directly in Java. Read more »
Externalizable is an interface which contains two methods readExternal and writeExternal. These methods give you a control over the serialization mechanism. Thus... Read more »
In Java the arguments are always passed by value . Read more »
No, a top level class can not be private or protected. It can have either “public” or no modifier. If it does not have a modifier it is supposed to have... Read more »
In declaration we just mention the type of the variable and it’s name. We do not initialize it. But defining means declaration + initialization. e.g String... Read more »
Nested top-level classes, Member classes, Local classes, Anonymous classes Nested top-level classes- If you declare a class within a class and specify the static... Read more »
When a class defines a method using the same name, return type, and arguments as a method in its superclass, the method in the class overrides the method in the... Read more »