Niraj Sharma
Also whatever you admins say about this section/page. This so called paper solution section is not even compete.
class H
{
final void show()
{
System.out.println("Final Method. Cant Override");
}
}
final class E extends H
{
//void show()
//{
// Can Not Override Final Method from H
//}
}
//class J extends E
//{
// Can Not Subclass Of E
//}
public class FinalKeywordSimpleExampleH2E
{
public static void main(String args[])
{
H h = new H();
h.show();
}
}
class employee(b) Declare a class called employee having employee_id and employee_name as members. Extend class employee to have a subclass called salary having designation and monthly_salary as members. Define following:
{
int employee_id;
String employee_name;
employee(int employee_id, String employee_name)
{
this.employee_id = employee_id;
this.employee_name = employee_name;
}
}
class salary extends employee
{
String designation;
double monthly_salary;
salary(int employee_id, String employee_name,String designation,double monthly_salary)
{
super(employee_id,employee_name);
this.designation = designation;
this.monthly_salary = monthly_salary;
}
void show()
{
System.out.println("Employee Details : ");
System.out.println("Id = "+this.employee_id);
System.out.println("Name = "+this.employee_name);
System.out.println("Designation = "+this.designation);
System.out.println("Salary = "+this.monthly_salary);
}
}
class SuperKeywordSimpleEampleH2E
{
public static void main(String args[])
{
salary s = new salary(1,"Shruti Patel","HR Manager",30000);
s.show();
}
}
class employee
{
int employee_id;
String employee_name;
}
class salary extends employee
{
String designation;
double monthly_salary;
salary()
{}
salary(int employee_id,String employee_name,String designation,double monthly_salary)
{
this.employee_id = employee_id;
this.employee_name = employee_name;
this.designation = designation;
this.monthly_salary = monthly_salary;
}
void findDataAbove20000(String arr[][])
{
for(int i=0;i<arr.length;i++)
{
if( (Double.parseDouble(arr[i][3]) ) > 20000 )
{
System.out.println("Employee Details : ");
System.out.println("Id = "+arr[i][0]);
System.out.println("Name = "+arr[i][1]);
System.out.println("Designation = "+arr[i][2]);
System.out.println("Salary = "+arr[i][3]);
}
}
}
}
public class employeeClassExampleInJavaH2E
{
public static void main(String args[])
{
salary s1[] = new salary[4];
String dataArr[][];
s1[0] = new salary(1,"Jaydip-Panchal","Finance-Manager",18000);
s1[1] = new salary(2,"Pratik-Patel","HR-Manager",29000);
s1[2] = new salary(3,"Arpan-Patel","Project-Manager",25000);
s1[3] = new salary();
try
{
s1[3].employee_id = Integer.parseInt(args[0]);
s1[3].employee_name = args[1];
s1[3].designation = args[2];
s1[3].monthly_salary = Double.parseDouble(args[3]);
//System.out.println(args[0]+args[1]+args[2]+args[3]);
}
catch(NumberFormatException e)
{
System.out.println("Exception : "+ e);
}
dataArr = new String[s1.length][4];
for(int i=0;i<s1.length;i++)
{
dataArr[i][0] = String.valueOf(s1[i].employee_id);
dataArr[i][1] = s1[i].employee_name;
dataArr[i][2] = s1[i].designation;
dataArr[i][3] = String.valueOf(s1[i].monthly_salary);
}
s1[3].findDataAbove20000(dataArr);
}
}