Semester : SEMESTER 6
Subject : Object Oriented Programming
Year : 2018
Term : MARCH
Scheme : 2015 Full Time
Course Code : EC 312
Page:14
Float number: 5.5
Integer number: 5 and float number: 5.5
5a. Exceptions in Java
An exception is an unwanted or unexpected event, which occurs during the execution of a program i.e
at run time, that disrupts the normal flow of the program’s instructions.
Error: An Error indicates serious problem that a reasonable application should not try to catch.
Exception: Exception indicates conditions that a reasonable application might try to catch.
Exception Hierarchy
All exception and errors types are sub classes of class Throwable, which is base class of
hierarchy.One branch is headed by Exception. This class is used for exceptional conditions that user
programs should catch. NullPointerException is an example of such வா exception.Another
branch,Error are used by the Java run-time system(J VM) to indicate errors having to do with the run-
time environment itself(JRE). StackOverflowError is an example of such an error.
Throwable
Checked Exceptions
Example: 10 or Compile
Virtual Machine Error
time Exception
Unchecked Exceptions
Example: Runtime or Null Assertion Error etc
Pointer Exceptions
5b. Virtual Function in C++
A virtual function a member function which is declared within base class and is re-defined (Overriden)
by derived class.When you refer to a derived class object using a pointer or a reference to the base
class, you can call a virtual function for that object and execute the derived class’s version of the
function.
« Virtual functions ensure that the correct function is called for an object, regardless of the type of
reference (or pointer) used for function call.