create named class

create named class

Can you check my coding@program:

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









Related Tutorials/Questions & Answers:
create named class - Java Beginners
create named class  Can you check my coding@program: How to create a class named Employee with name and salary. Make a class Manager inherit from...() that prints the manager?s name, department and salary. Make another class named
create a class
create a class  plz provide any example related to class
Advertisements
to create a java class and methods
to create a java class and methods  How to create a java class without using the library class to represent linked lists of integers and also provide it with methods that can be used to reverse a list & append two lists.Also
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
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
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
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 '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
Design a class named account
Design a class named account  The class contains: § An int data field named id for the account (default 0). § A double data field named balance for the account (default 0.0)ADS_TO_REPLACE_1 § A double data field named
Create a float buffer by using wrap method of FloatBuffer class.
Create a float buffer by using wrap method of FloatBuffer class. In this tutorial, we will see how to create a float buffer by using wrap method of FloatBuffer class. ByteBuffer API. The java.nio.FloatBuffer class extends
Create a short buffer by using wrap method of ShortBuffer class.
Create a short buffer by using wrap method of ShortBuffer class. In this tutorial, we will see how to create a shortt buffer by using wrap method of ShorttBuffer class. ShortBuffer API. The java.nio.ShortBuffer class extends
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
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
ModuleNotFoundError: No module named 'auto-class'
ModuleNotFoundError: No module named 'auto-class'  Hi, My Python... 'auto-class' How to remove the ModuleNotFoundError: No module named 'auto...-class python library, ModuleNotFoundError: No module named 'auto-class'
ModuleNotFoundError: No module named 'case_class'
ModuleNotFoundError: No module named 'case_class'  Hi, My Python... 'case_class' How to remove the ModuleNotFoundError: No module named 'case..._class python library, ModuleNotFoundError: No module named 'case_class'
ModuleNotFoundError: No module named 'class_extension'
ModuleNotFoundError: No module named 'class_extension'  Hi, My... named 'class_extension' How to remove the ModuleNotFoundError: No module named... named 'class_extension' error will be solved. Thanks
ModuleNotFoundError: No module named 'class-pool'
ModuleNotFoundError: No module named 'class-pool'  Hi, My Python... 'class-pool' How to remove the ModuleNotFoundError: No module named '...-pool python library, ModuleNotFoundError: No module named 'class-pool'
ModuleNotFoundError: No module named 'class-property'
ModuleNotFoundError: No module named 'class-property'  Hi, My... named 'class-property' How to remove the ModuleNotFoundError: No module named... the installation of class-property python library, ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'class_proxy'
ModuleNotFoundError: No module named 'class_proxy'  Hi, My Python... 'class_proxy' How to remove the ModuleNotFoundError: No module named '... of class_proxy python library, ModuleNotFoundError: No module named 'class_proxy
ModuleNotFoundError: No module named 'class-registry'
ModuleNotFoundError: No module named 'class-registry'  Hi, My... named 'class-registry' How to remove the ModuleNotFoundError: No module named... the installation of class-registry python library, ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'class-tools'
ModuleNotFoundError: No module named 'class-tools'  Hi, My Python... 'class-tools' How to remove the ModuleNotFoundError: No module named '... of class-tools python library, ModuleNotFoundError: No module named 'class-tools
ModuleNotFoundError: No module named 'class-tools'
ModuleNotFoundError: No module named 'class-tools'  Hi, My Python... 'class-tools' How to remove the ModuleNotFoundError: No module named '... of class-tools python library, ModuleNotFoundError: No module named 'class-tools
ModuleNotFoundError: No module named 'class-utils'
ModuleNotFoundError: No module named 'class-utils'  Hi, My Python... 'class-utils' How to remove the ModuleNotFoundError: No module named '... of class-utils python library, ModuleNotFoundError: No module named 'class-utils
ModuleNotFoundError: No module named 'class-utils'
ModuleNotFoundError: No module named 'class-utils'  Hi, My Python... 'class-utils' How to remove the ModuleNotFoundError: No module named '... of class-utils python library, ModuleNotFoundError: No module named 'class-utils
ModuleNotFoundError: No module named 'db_class'
ModuleNotFoundError: No module named 'db_class'  Hi, My Python..._class' How to remove the ModuleNotFoundError: No module named 'db_class... library, ModuleNotFoundError: No module named 'db_class' error
ModuleNotFoundError: No module named 'django-class'
ModuleNotFoundError: No module named 'django-class'  Hi, My Python... 'django-class' How to remove the ModuleNotFoundError: No module named '... of django-class python library, ModuleNotFoundError: No module named 'django
ModuleNotFoundError: No module named 'django-class'
ModuleNotFoundError: No module named 'django-class'  Hi, My Python... 'django-class' How to remove the ModuleNotFoundError: No module named '... of django-class python library, ModuleNotFoundError: No module named 'django
ModuleNotFoundError: No module named 'django-class'
ModuleNotFoundError: No module named 'django-class'  Hi, My Python... 'django-class' How to remove the ModuleNotFoundError: No module named '... of django-class python library, ModuleNotFoundError: No module named 'django
ModuleNotFoundError: No module named 'hz_class'
ModuleNotFoundError: No module named 'hz_class'  Hi, My Python..._class' How to remove the ModuleNotFoundError: No module named 'hz_class... library, ModuleNotFoundError: No module named 'hz_class' error
ModuleNotFoundError: No module named 'MyPackage_Class'
ModuleNotFoundError: No module named 'MyPackage_Class'  Hi, My... named 'MyPackage_Class' How to remove the ModuleNotFoundError: No module named... named 'MyPackage_Class' error will be solved. Thanks
ModuleNotFoundError: No module named 'note_class'
ModuleNotFoundError: No module named 'note_class'  Hi, My Python... 'note_class' How to remove the ModuleNotFoundError: No module named 'note..._class python library, ModuleNotFoundError: No module named 'note_class'
ModuleNotFoundError: No module named 'radio-class'
ModuleNotFoundError: No module named 'radio-class'  Hi, My Python... 'radio-class' How to remove the ModuleNotFoundError: No module named '... of radio-class python library, ModuleNotFoundError: No module named 'radio-class
ModuleNotFoundError: No module named 'scraping-class'
ModuleNotFoundError: No module named 'scraping-class'  Hi, My... named 'scraping-class' How to remove the ModuleNotFoundError: No module named... the installation of scraping-class python library, ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'Xymon_Class'
ModuleNotFoundError: No module named 'Xymon_Class'  Hi, My Python... 'Xymon_Class' How to remove the ModuleNotFoundError: No module named '... of Xymon_Class python library, ModuleNotFoundError: No module named 'Xymon_Class
ModuleNotFoundError: No module named 'auto-class'
ModuleNotFoundError: No module named 'auto-class'  Hi, My Python... 'auto-class' How to remove the ModuleNotFoundError: No module named 'auto...-class python library, ModuleNotFoundError: No module named 'auto-class'
ModuleNotFoundError: No module named 'blockdiagcontrib-class'
ModuleNotFoundError: No module named 'blockdiagcontrib-class'  Hi...: No module named 'blockdiagcontrib-class' How to remove the ModuleNotFoundError: No module named 'blockdiagcontrib-class' error? Thanks   Hi
ModuleNotFoundError: No module named 'case_class'
ModuleNotFoundError: No module named 'case_class'  Hi, My Python... 'case_class' How to remove the ModuleNotFoundError: No module named 'case..._class python library, ModuleNotFoundError: No module named 'case_class'
ModuleNotFoundError: No module named 'Check-class'
ModuleNotFoundError: No module named 'Check-class'  Hi, My Python... 'Check-class' How to remove the ModuleNotFoundError: No module named '... of Check-class python library, ModuleNotFoundError: No module named 'Check-class
ModuleNotFoundError: No module named 'class-cli'
ModuleNotFoundError: No module named 'class-cli'  Hi, My Python... 'class-cli' How to remove the ModuleNotFoundError: No module named 'class... python library, ModuleNotFoundError: No module named 'class-cli' error
ModuleNotFoundError: No module named 'class-decoration'
ModuleNotFoundError: No module named 'class-decoration'  Hi, My... named 'class-decoration' How to remove the ModuleNotFoundError: No module named 'class-decoration' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'class-doc'
ModuleNotFoundError: No module named 'class-doc'  Hi, My Python... 'class-doc' How to remove the ModuleNotFoundError: No module named 'class... python library, ModuleNotFoundError: No module named 'class-doc' error
ModuleNotFoundError: No module named 'class_extension'
ModuleNotFoundError: No module named 'class_extension'  Hi, My... named 'class_extension' How to remove the ModuleNotFoundError: No module named... named 'class_extension' error will be solved. Thanks
ModuleNotFoundError: No module named 'class-namespaces'
ModuleNotFoundError: No module named 'class-namespaces'  Hi, My... named 'class-namespaces' How to remove the ModuleNotFoundError: No module named 'class-namespaces' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'class-pool'
ModuleNotFoundError: No module named 'class-pool'  Hi, My Python... 'class-pool' How to remove the ModuleNotFoundError: No module named '...-pool python library, ModuleNotFoundError: No module named 'class-pool'
ModuleNotFoundError: No module named 'class-property'
ModuleNotFoundError: No module named 'class-property'  Hi, My... named 'class-property' How to remove the ModuleNotFoundError: No module named... the installation of class-property python library, ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'class_proxy'
ModuleNotFoundError: No module named 'class_proxy'  Hi, My Python... 'class_proxy' How to remove the ModuleNotFoundError: No module named '... of class_proxy python library, ModuleNotFoundError: No module named 'class_proxy

Ads