Answer to Question #212734 in Java | JSP | JSF for Karon Aldrich

Question #212734

come up with an example of a *class hierarchy* of at least 2 classes you argue would be needed for an application of your choice.


1
Expert's answer
2021-07-02T04:11:12-0400
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) {
		Employee e=new Employee();
		e.displayInfo();
	}
}
class Employee{
    private String fname;
    private String lname;
    private int empNo;
    private int age;
    
    private void getInfo(){
        Scanner in =new Scanner(System.in);
        System.out.print("First Name: ");
        fname=in.next();
        System.out.print("Second Name: ");
        lname=in.next();
        System.out.print("Employee number: ");
        empNo=in.nextInt();
        System.out.print("Age: ");
        age=in.nextInt();
    }
    public void displayInfo(){
        getInfo();
        System.out.println("First Name: "+fname);
        System.out.println("Second Name: "+lname);
        System.out.println("Employee number: "+empNo);
        System.out.println("Age: "+age);
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS