1)
-----------------------------------------------------------------
public class Employee {
String name;
int age;
String desg;
double sal;
public Employee(String name)
{
this.name=name;
}
public void empAge(int age)
{
this.age=age;
}
public void empDesg(String desg)
{
this.desg=desg;
}
public void empSal(double sal)
{
this.sal=sal;
}
void printEmployee()
{
System.out.println("Name : "+name);
System.out.println("Age : "+age);
System.out.println("Desg : "+desg);
System.out.println("Salary : "+sal);
}
}
------------------------------------------------------------
public class EmployeeTest{
public static void main(String args[])
{
Employee empOne=new Employee("sree");
empOne.empAge(24);
empOne.empDesg("developer");
empOne.empSal(11280.50);
empOne.printEmployee();
Employee empTwo=new Employee("krishna");
empTwo.empAge(21);
empTwo.empDesg("soft developer");
empTwo.empSal(11580);
empTwo.printEmployee();
}
}
----------------------------------------------------------------------------------------------------------------------
2)
public class FindMin {
public static void main(String args[])
{
int a,b,c;
a=5;
b=9;
c=minfn(a,b);
System.out.println("in main:"+c);
}
public static int minfn(int x, int y)
{
int min;
if (x>y)
min =y;
else min=x;
System.out.println(min);
return min;
}
}
-----------------------------------------------------------------
public class Employee {
String name;
int age;
String desg;
double sal;
public Employee(String name)
{
this.name=name;
}
public void empAge(int age)
{
this.age=age;
}
public void empDesg(String desg)
{
this.desg=desg;
}
public void empSal(double sal)
{
this.sal=sal;
}
void printEmployee()
{
System.out.println("Name : "+name);
System.out.println("Age : "+age);
System.out.println("Desg : "+desg);
System.out.println("Salary : "+sal);
}
}
------------------------------------------------------------
public class EmployeeTest{
public static void main(String args[])
{
Employee empOne=new Employee("sree");
empOne.empAge(24);
empOne.empDesg("developer");
empOne.empSal(11280.50);
empOne.printEmployee();
Employee empTwo=new Employee("krishna");
empTwo.empAge(21);
empTwo.empDesg("soft developer");
empTwo.empSal(11580);
empTwo.printEmployee();
}
}
----------------------------------------------------------------------------------------------------------------------
2)
public class FindMin {
public static void main(String args[])
{
int a,b,c;
a=5;
b=9;
c=minfn(a,b);
System.out.println("in main:"+c);
}
public static int minfn(int x, int y)
{
int min;
if (x>y)
min =y;
else min=x;
System.out.println(min);
return min;
}
}
--------------------------------------------------------------------------------------------------------------
3)
public class methodOver {
public static void main(String args[])
{
int a=3,b=4;
double c=1.3,d=3.5;
int res=minfn(a,b);
double resy=minfn(c,d);
System.out.println("int:"+res);
System.out.println("double: "+resy);
}
public static int minfn(int x,int y)
{
int min;
if (x>y)
min=y;
else min=x;
return min;
}
public static double minfn(double a,double b)
{
double min;
//a>b?min=b:min=a;
if(a>b)
min=b;
else min=a;
return min;
}
}
-------------------------------------------------------------------------------------------
4)
No comments:
Post a Comment