Tag: J2SE
How many ways can we make an object eligible for GC? Even through programmer is not responsible to destroy useless objects it is highly recommended to make an object eligible for GC. If it no longer a requirement. The garbage collector will look for objects which aren’t being used anymore . . . Read more
What is synchronization and why it is important? Synchronized is the modifier applicable only for methods and blocks but not for classes and variables. If multiple threads are trying to operate simultaneously on the same java object then there may be a chance of data-inconsistency problem. To overcome this problem we should go . . . Read more
Explain thread priority and what is default thread priority? Every thread in java has some priority. It may be default priority generated by JVM or customized priority provided by the programmer. The valid range of thread priorities is 1-10. where 1 is min priority and 10 is the max priority. . . . Read more
What is finally block in Java? It is not recommended to maintain cleanup code inside try block because there is no guarantee for the execution of every statement inside the try block. It is not recommended to maintain cleanup code inside the catch block. Because if there is no exception . . . Read more
What is the checked and unchecked exception? The exceptions which are checked by the compiler for smooth execution of the program are called checked exceptions. In our program, if there is a chance of raising checked exception then compulsory we should handle that checked exception either by try-catch or by . . . Read more
Explain Default exception handling in Java? Inside a method, if any exception occurs the method in which it is raised is responsible to create exception object by including the following information. Name of exception Description of exception Location at which exception occurs(Stack trace). After creating exception object method handover that . . . Read more
What is Exception and Runtime stack mechanism? An unexpected unwanted even that disturbs normal flow of the program is called an exception. It is highly recommended to handle the exceptions and the main objective of exception handling is graceful termination of the program. Exception Handling doesn’t mean repairing an exception. . . . Read more
Difference between IS-A relationship and Has-A relationship. IS-A Relationship It is known as an inheritance The main advantage of IS-A relationship is code reusability. By using extends keyword we can implement IS-A relationship. Whatever method parent has by-default available to the child and hence on the child reference we can call . . . Read more
What is Encapsulation? The process of binding data and corresponding method into a single unit is nothing but encapsulation. If any component follows Data Hiding and Abstraction such type of component is said to be encapsulated component. Encapsulation = Data hiding + Abstraction. Encapsulation is a principle of wrapping data . . . Read more
What is Volatile keyword in Java? Volatile is the modifier applies only to variables and we can’t apply anywhere else. If the value of a variable keeps on changing by multiple threads then there may be a chance of data inconsistency problem. We can solve this problem by using the . . . Read more