Posts

UNit-3 : Exception Handling

Image
  An exception is a runtime error, which will distrupts the normal flow of application.   Checked exceptions checked exception is an exception that occurs at the compile time, these are also called as compile time exceptions. 1. ClassNotFoundException : This exception is thrown when the JVM tries to load a class, which is not present in the classpath.    Class.forName("oracle.jdbc.driver.OracleDriver");   2. FileNotFoundException : This exception is thrown when the program tries to access a file that does not exist or does not open. This error occurs mainly in file handling programs. File file = new File("E:// file.txt"); FileReader fr = new FileReader(file);   3. IOException : This exception is thrown when the input-output operation in a program fails or is interrupted during the program’s execution.   4. InterruptedException : This exception occurs whenever a thread is processing, sleeping or waiting in a multithreading program and it is interrup...

Inheritance

Image
  UNIT-2 Inheritance in java is a mechanism in which one object acquires the properties and behaviors of another object. Advantages of inheritance in java 1.For Method overriding (so runtime Polymorphism can be achieved). 2.For Code Reusability, Extend the functionality. 3.It allows creation of Hierarchical Classification. Syntax: class Subclass-name extends Superclass-name { //methods and fields of sub class }   Types of inheritance 1.Single Level Inheritance: A super class is inherited by only one sub class. 2.Multi Level Inheritance: A sub-class will be inheriting parent class and as well as, the sub-class act as a parent class to other class., and so on.     3.Hierarchical Inheritance: A Super is inherited by many sub classes.     4.Multiple Inheritance: (not supported by java) A sub class extending more than one super class.     5.  Hybrid Inheritance: (not supported by java) It is a combination of Multiple and Multilevel inherita...