CODING:
class current{
double current;
double resistance;
//Creating Parameterize constructor
current (double current,double resistance)
{
this.current = current;
this.resistance = resistance;
}
double volt()
{
return current*resistance;
}
}
class voltage
{
public static void main(String args[])
{
//Creating Object Of current class
current cur=new current(10,40);
current cur1=new current(30,10);
System.out.println("Voltage is = "+cur.volt()+" volt");
System.out.println("Voltage is = "+cur1.volt()+" volt");
}
}
OUTPUT:
voltage is=400volt
voltage is=300volt
This keyword in Java
ReplyDeleteThanks for sharing this post