create named class

Ads
 

create named class

Can you check my [email protected]:

How to create a class named Employee with name and salary. Make a class Manager inherit from Employee with an instance field named department. Supply a method toString() that prints the manager?s name, department and salary. Make another class named Director which inherits from Manager that has an instance field named carAllowanceAmount. Supply the toString() method for Director that prints all of its instance variables. Also, write a program name TestQ3 that instantiates an object of each of these classes and invokes the toString() method of each of these object.
(Note: all instance variables must be assigned with private accessibility and methods with public accessibility)

My coding :


class Employee {
private String name = "Zam Norfaizah Binti Zain Baharin";
private int salary = 2500;

public String toString() {
return "Name : " + name + "\nSalary : " + salary;
}
}
class Manager extends Employee {
private String departName = "College Art and Sciences";

public String toString() {
return super.toString() + "\nDepartment Named : " + departName;
}
}
class Director extends Manager {
private int carAllowanceAmount = 500;

public String toString() {
return "The car allowance amount is : " + carAllowanceAmount;
}
}
public class TestQ3 {
public static void main(String args[]) {
Manager mnger = new Manager();
System.out.println(mnger.toString());
Director dir = new Director();
System.out.println(dir.toString());
}
}


Can you comment and give the reason? what the true coding?
View Answers

Ads









Related Tutorials/Questions & Answers:
create a class
create a class  plz provide any example related to class
How to create a class in java
How to create a class in java  I am a beginner in programming and tried to learn how to do programming in Java. Friends please explain how can I create a class in Java
Advertisements
Can you create an object of an abstract class?
Can you create an object of an abstract class?   Hi, Can you create an object of an abstract class? Thanks
Create Action class
Create Action Class An action is an important portion of web application... an action class you need to extend or import the Action classes or interface... package. The commonly used action class is ActionSupport. An example of action
a class named Transactions
a class named Transactions  Write this java code for me: a class named Transactions that holds the memo and the amount of a transaction. Prompt the user for the number of transactions and create a new Transaction object
ModuleNotFoundError: No module named 'create'
ModuleNotFoundError: No module named 'create'  Hi, My Python... 'create' How to remove the ModuleNotFoundError: No module named 'create'..., ModuleNotFoundError: No module named 'create' error will be solved. Thanks
ModuleNotFoundError: No module named 'create'
ModuleNotFoundError: No module named 'create'  Hi, My Python... 'create' How to remove the ModuleNotFoundError: No module named 'create'..., ModuleNotFoundError: No module named 'create' error will be solved. Thanks
ModuleNotFoundError: No module named 'class'
ModuleNotFoundError: No module named 'class'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'class' How to remove the ModuleNotFoundError: No module named 'class'
ModuleNotFoundError: No module named 'class_a'
ModuleNotFoundError: No module named 'class_a'  Hi, My Python... 'class_a' How to remove the ModuleNotFoundError: No module named 'class..., ModuleNotFoundError: No module named 'class_a' error will be solved
ModuleNotFoundError: No module named 'class'
ModuleNotFoundError: No module named 'class'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'class' How to remove the ModuleNotFoundError: No module named 'class'
ModuleNotFoundError: No module named 'class_a'
ModuleNotFoundError: No module named 'class_a'  Hi, My Python... 'class_a' How to remove the ModuleNotFoundError: No module named 'class..., ModuleNotFoundError: No module named 'class_a' error will be solved
create a named screen in linux
create a named screen in linux  Hi, I want to create a screen... of your guys to tell me the command. How to create a named screen in linux... is an example: screen -S myapp Above command will create screen with the name my
create
create  how to create an excel file using java
ModuleNotFoundError: No module named 'create_jobs'
ModuleNotFoundError: No module named 'create_jobs'  Hi, My Python... 'create_jobs' How to remove the ModuleNotFoundError: No module named '... of create_jobs python library, ModuleNotFoundError: No module named 'create_jobs
ModuleNotFoundError: No module named 'create-folder'
ModuleNotFoundError: No module named 'create-folder'  Hi, My... 'create-folder' How to remove the ModuleNotFoundError: No module named... the installation of create-folder python library, ModuleNotFoundError: No module named '
ModuleNotFoundError: No module named 'create-package'
ModuleNotFoundError: No module named 'create-package'  Hi, My... named 'create-package' How to remove the ModuleNotFoundError: No module named... the installation of create-package python library, ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'create-project'
ModuleNotFoundError: No module named 'create-project'  Hi, My... named 'create-project' How to remove the ModuleNotFoundError: No module named... the installation of create-project python library, ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'create_jobs'
ModuleNotFoundError: No module named 'create_jobs'  Hi, My Python... 'create_jobs' How to remove the ModuleNotFoundError: No module named '... of create_jobs python library, ModuleNotFoundError: No module named 'create_jobs
ModuleNotFoundError: No module named 'create-pypkg'
ModuleNotFoundError: No module named 'create-pypkg'  Hi, My Python... 'create-pypkg' How to remove the ModuleNotFoundError: No module named '... of create-pypkg python library, ModuleNotFoundError: No module named 'create
ModuleNotFoundError: No module named 'create-package'
ModuleNotFoundError: No module named 'create-package'  Hi, My... named 'create-package' How to remove the ModuleNotFoundError: No module named... the installation of create-package python library, ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'create-project'
ModuleNotFoundError: No module named 'create-project'  Hi, My... named 'create-project' How to remove the ModuleNotFoundError: No module named... the installation of create-project python library, ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'create-pypkg'
ModuleNotFoundError: No module named 'create-pypkg'  Hi, My Python... 'create-pypkg' How to remove the ModuleNotFoundError: No module named '... of create-pypkg python library, ModuleNotFoundError: No module named 'create
ModuleNotFoundError: No module named 'create-readme'
ModuleNotFoundError: No module named 'create-readme'  Hi, My... 'create-readme' How to remove the ModuleNotFoundError: No module named... the installation of create-readme python library, ModuleNotFoundError: No module named '
ModuleNotFoundError: No module named 'create-redirect'
ModuleNotFoundError: No module named 'create-redirect'  Hi, My... named 'create-redirect' How to remove the ModuleNotFoundError: No module named... named 'create-redirect' error will be solved. Thanks
ModuleNotFoundError: No module named 'create-readme'
ModuleNotFoundError: No module named 'create-readme'  Hi, My... 'create-readme' How to remove the ModuleNotFoundError: No module named... the installation of create-readme python library, ModuleNotFoundError: No module named '
ModuleNotFoundError: No module named 'create-redirect'
ModuleNotFoundError: No module named 'create-redirect'  Hi, My... named 'create-redirect' How to remove the ModuleNotFoundError: No module named... named 'create-redirect' error will be solved. Thanks
ModuleNotFoundError: No module named 'create-subject'
ModuleNotFoundError: No module named 'create-subject'  Hi, My... named 'create-subject' How to remove the ModuleNotFoundError: No module named... the installation of create-subject python library, ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'Dir-Create'
ModuleNotFoundError: No module named 'Dir-Create'  Hi, My Python... 'Dir-Create' How to remove the ModuleNotFoundError: No module named 'Dir...-Create python library, ModuleNotFoundError: No module named 'Dir-Create'
ModuleNotFoundError: No module named 'dtool-create'
ModuleNotFoundError: No module named 'dtool-create'  Hi, My Python... 'dtool-create' How to remove the ModuleNotFoundError: No module named '... of dtool-create python library, ModuleNotFoundError: No module named 'dtool
ModuleNotFoundError: No module named 'github-create'
ModuleNotFoundError: No module named 'github-create'  Hi, My... 'github-create' How to remove the ModuleNotFoundError: No module named... the installation of github-create python library, ModuleNotFoundError: No module named '
ModuleNotFoundError: No module named 'github-create'
ModuleNotFoundError: No module named 'github-create'  Hi, My... 'github-create' How to remove the ModuleNotFoundError: No module named... the installation of github-create python library, ModuleNotFoundError: No module named '

Ads