OCPJP 6 Mock Exam -12

ocpjp-6-thumbnail

1 . What will be the output? Choose the one below: the code will compile an print “Equal”. the code will compile an print “Not Equal”. the code will cause a compiler error. 2 . What will be the output? Choose the one below: the code will compile an print “Equal”. the code will compile […]

OCPJP 6 Mock Exam -11

ocpjp-6-thumbnail

1 . Consider following classes: What will be the output of running class Test? false false true false true false true true false true true true true true true true true true false true None of the above 2 . Any class may be unloaded when none of it’s instances and class objects that represent […]

ArrayList in Java

java-thumbnail

ArrayList is most widely used collections API for storing the list of objects. This class is equivalent to Vector, except that it is unsynchronized. Look at the below important points about the class ArrayList. It allows null values It stores the duplicate elements The size of the list is grows dynamically when more elements are […]

Runtime Exceptions in Java

java-thumbnail

Runtime exceptions are need not be handled by the programs. Generally RuntimeExceptions are exceptions that can be prevented programmatically.E.g NullPointerException, ArrayIndexOutOfBoundException. If we check for null value before calling any method, NullPointerException would never occur. These kind of exceptions should never be handled because that is not good practice. Java has 49 Runtime exceptions defined […]

Difference Between Throw and Throws in Exception Handling

java-thumbnail

When you are working with exception handling in Java, use of throw and throws may confuse you if you not familiar with the exception handling. Both are important keywords used frequently used in handling the exceptions. Throw is used for explicitly throwing an exception. Throw attribute in method signature, is a hint to the compiler […]

Try, Catch and Finally in Exception Handling

java-thumbnail

The basic procedure to handle the exception is to use the try-catch block. If you want to put any code that would cause a exception, then write that piece of code inside the try-catch block. If you expect multiple type of exceptions in the same block, then you can write more than one catch block […]

Exception Handling in Java

java-thumbnail

Exception handling is one of the important task for every programmer. For a successful project completion, proper exception handling is important. Exception is an abnormal error encountered by program which is not anticipated by the program, but it is the responsibility of a developer to gracefully handle the exceptions and redirect with suitable error message […]

Constructor in Java

java-thumbnail

Constructors are special type of methods that are invoked at the time of creating the objects. If you use new keyword for creating the object, the constructors are called. There are certain restrictions imposed on these special type of methods. Constructors should have the same name as class name Constructors should not have any return […]

Method Overloading Vs Overriding in Java

java-thumbnail

In our previous tutorials we have explained about the method overloading and method overriding in Java. Read those tutorials for the more explanations. This tutorial highlights the only differences and when we have to use both the concepts. Both the concepts are based on the polymorphism in Java. Look at the below table for the […]

Method Overloading in Java

java-thumbnail

Method Overloading is the concept of writing multiple methods with the same name. Here the common characteristic is only the name. Parameters must be different. Return type can be anything. Also note that method overloading is within same class or inherited class. Look at the below points on how to overload a method. All the […]