Professional Documents
Culture Documents
3.oops Notes
3.oops Notes
----
As we know java is an object oriented programming language.
*every java programme on execution created one or more objects and calls method
as we know programme call method to perform task.
Note:
-----
Remember one variable can store/hold only one value.
Answer:
for a single patient we need to write the code as follows:
//write a programme to show the details of 1 patient.
import java.util.Scanner;
firstname1="Manish";
lastname1="Kumar";
weight1=70.25;
height1=5.65;
age1=24;
firstname2="Kanhaiya";
lastname2="Kumar";
weight2=24.56;
height2=6.45;
age2=25;
firstname3="Raja";
lastname3="Kumar";
weight3=25.54;
height3=10.5;
age3=24;
System.out.println("..............First Patient
Details................");
System.out.println("first name is:"+firstname1);
System.out.println("Last name is:"+lastname1);
System.out.println("weight is:"+weight1);
System.out.println("height is:"+height1);
System.out.println("age is:"+age1);
System.out.println("..............Second Patient
Details................");
System.out.println("first name is:"+firstname2);
System.out.println("Last name is:"+lastname2);
System.out.println("weight is:"+weight2);
System.out.println("height is:"+height2);
System.out.println("age is:"+age2);
System.out.println("..............Third Patient
Details................");
System.out.println("first name is:"+firstname3);
System.out.println("Last name is:"+lastname3);
System.out.println("weight is:"+weight3);
System.out.println("height is:"+height3);
System.out.println("age is:"+age3);
solution:
Rather the defining varibales for each parameter and asigning value to each
varibale , we need to define a
template to achieve this.