PSOOP - Expt 2a - 014 - HogadeDhruv
PSOOP - Expt 2a - 014 - HogadeDhruv
Default constructor:
If there are no constructors written for a class, Java provides a no-
argument default constructor where the instance variables are set to
their default values. For int and double variables, the default value
used is 0 and for String and other object variables, the default is null.
Parameterized constructor:
Constructors with parameters that can be used to initialize the internal
state (fields) of the newly created object are known as Parameterized
Constructors. If we want to initialize fields of the class with our own
values, then use a parameterized constructor.
Power function:
The syntax of the pow() method is: Math.pow(double num1, double num2)
Power function in Java is used to calculate a number raised to the
power of some other number. This function accepts two parameters
and returns the value of the first parameter raised to the second
parameter.
m.menuoption();
}
}
class Menu{
Scanner sc=new Scanner(System.in);
void deposit(double depo){
void menuoption(){
System.out.println("Enter the account balance and rate
of interest:");
Bankacc u1=new
Bankacc(sc.nextDouble(),sc.nextDouble());
System.out.println("Enter 1 to continue to menuoption or 0
to exit.");
int i=sc.nextInt();
while(i!=0)
{
}
}
}
}
RESULT:
CONCLUSION: This experiment is based on the use of constructor .I learnt how to create a
Parameterized constructor ,to initialize the variables created and call it to use by creating
object