Dhruv Exp10
Dhruv Exp10
Problem Statement 1:
.Demonstrate using a suitable example that a base class reference variable can point
to a child class object or a base class object using the concept of dynamic method
Code:
class JavaExp10{
A.print();
B.print();
class superclass{
System.out.println("this is superclass");
System.out.println("this is subclass");
Output
Problem Statement 2:
Adwita , 8th Grade student wants to write a functions to calculate simple interest,
compound interest. She wants to keep same (final) rate of interest for every input of
principal and time. She wants to ensure that the declared functions are not
overridden in any subclasses and the class is not inherited by any other class. Help
her to declare the variables methods and classes and write the code for the same
Code:
import java.util.Scanner;
Output
Problem Statement 3:
Code:
@Override
super.finalize();
obj = null;
System.gc();
Output