Exceptions in JDBC: java.sql.SQLException is a core JDBC exception class that provides information about database access errors and other errors. Most of the JDBC API methods throws SQLException. Extends the java.lang.Exception class java.sql.BatchUpdateException : a BatchUpdateException which provides an update counts for all commands that were su...

Read More

SQL JDBC Exception Handling : SQLWarning objects are a subclass of SQLException that deal with database access warnings. Warnings do not stop the execution of an application, as exceptions do, they simply alert the user that something did not happen as planned. For example, a warning might let you know that a privilege you attempted to revoke was n...

Read More

Method forName() is a static method of java.lang.Class. This can be used to dynamically load a class at run-time. Class.forName() loads the class if its not already loaded. It also executes the static block of loaded class. Then this method returns an instance of the loaded class. So a call to Class.forName(‘MyClass’) is going to do following Load ...

Read More

Object cloning means creating a copy of an object. There are various means of doing this. Most common are Copy Constructors and Cloning. Cloning is done mostly so the copy can be modified or moved, or the current value preserved. If either of these is unneeded, a reference to the original data is sufficient and more efficient, as no copying occurs....

Read More

In Java there is a clone() method declared in the Object class. The objective of this method is to clone the calling object. However to use this method from any class, that class needs to implement the Cloneable interface else an Exception will be thrown at runtime (CloneNotSupportedException). clone() acts like a copy constructor. Typically it cal...

Read More

Java uses the clone() method to create a copy of an object. By default this copy is a shallow copy of the original object. To achieve deep copy you would need to make some changes in the class. Consider the image below. 1. Shallow copy : If a shallow copy is performed on the Obj-1 as shown in Img-1 then it is copied but it's containing objects are ...

Read More

A class that is derived from another class is called a subclass (also a derived class, extended class, or child class). The class from which the subclass is derived is called a superclass (also a base class or a parent class). Excepting Object, which has no superclass, every class has one and only one direct superclass (single inheritance). In the ...

Read More

Below are Various types of inheritance in Java. We will see each one of them one by one. 1) Single Inheritance : Single inheritance is easy to understand. When a class extends another one class only then we  call it a single inheritance. The below flow diagram shows that class B extends only one class which is A. Here A is a parent class of B and B...

Read More

Declaring a method in subclass which is already present in parent class is known as method overriding. The following is an example of method overriding : abstract class Mammal { protected abstract String move(); } class Human extends Mammal { @Override protected String move() { return "I walk to move !!"; } } class Whale ex...

Read More

The ‘is a’ relationship is expressed with inheritance and ‘has a’ relationship is expressed with composition. Both inheritance and composition allow you to place sub-objects inside your new class. Two of the main techniques for code reuse are class inheritance and object composition.   Inheritance is uni-directional. For example House is a Building...

Read More

FOLLOW US ON LinkedIn



Explore Tutu'rself