Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners create named class

Have Programming Question? Ask it here!
 
 
 


zam
create named class
0 Answer(s)      4 years and 7 months ago
Posted in : Java Beginners


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?

Advertisement
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
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
Advertisements
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) § A double data field named annualInterestRate
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
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
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
Design a class named BankAccount to hold datas for a bank account in Java using Bluej Software - Java Interview Questions
Design a class named BankAccount to hold datas for a bank account in Java using Bluej Software  1)Design a class named BankAccount to hold... service charges The class should have the following methods: Constructor
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
Hibernate Named HQL in Annotation
In this section, you will learn how to execute Named HQL written in Model class Annotation
Hibernate Named Native SQL in Annotation
In this section, you will learn how to execute the Named Native SQL written in Model class Annotation
Hibernate named queries
Hibernate named queries  Hi, What is named queries in Hibernate? Thanks
Named ? SQL query in hibernate
Named ? SQL query in hibernate  What is Named SQL query in hibernate...;hibernate-mapping> <class name="com.test.Product" table="product">... name="ID" /> <generator class="identity" /> <
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
Database named studentinfo
Database named studentinfo  1.create design of studentinfo using swing component 2.Create a database named student info. 3.create a table that stores all the details from the form,application of basic Normalization is required
Database named studentinfo
Database named studentinfo  1.create design of studentinfo using swing component 2.Create a database named student info. 3.create a table that stores all the details from the form,application of basic Normalization is required
Database named studentinfo
Database named studentinfo  1.create design of studentinfo using swing component 2.Create a database named student info. 3.create a table that stores all the details from the form,application of basic Normalization is required
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
Hibernate Named Query
This section contain description of named query with example
JPA setParameter (Named Parameter)
JPA setParameter (Named Parameter)   ... API's method setParameter as a named parameter. JPA Query API's supports two types of setParameter.  1. Named Parameters  2. Numbered Parameters
can i restrict a class that it will not allows create more than two objects - Java Interview Questions
can i restrict a class that it will not allows create more than two objects  hi all, can i restrict a class that it will not allows create more than two objects can any help me please. Thaks bala k
JPA Named Parameter List
JPA Named Parameter List   ... application using JPA Named Parameter List. This is similar as named parameter but here we use the an array list as named parameter.  Named Parameter List
JPA Named Parameter
JPA Named Parameter       In this section, you will learn how to use JPA Named Parameter in your jpa application. In JPA named parameter is used where you assign names
create
create  how to create an excel file using java
JPA Named Queries
JPA Named Queries       In this section, you will know about the JPA Named Queries...;) }) For developing JPA Named Queries, you need the following files
Hibernate Named Query
Hibernate Named Query       Named Query is very useful concept in hibernate. It lets....dtd"> <hibernate-mapping> <class name="
class
class  Is a class a subclass of itself
Hibernate Named Native SQL Query
In this section, you will learn Named Native SQL Query in Hibernate
class name
class name  how to create a class named box thaT INCLUDES integer data fields for length,width,and height, include three contructors that require one,two,three arguments
class
is a class to represent a country in medal tally. It has an attribute of country... medals. In this class, you should also define constructors, and assessor, mutator methods. Task 2 MedalTally.java is a class to model a medal tally, containing
Class
Class, Object and Methods       Class : Whatever we can see in this world all the things... is termed as a class. All the objects are direct interacted with its class
Write a program named InternetCharge_YourLastName that do the following:
. Instruction: We should have two classes class named InternetService...Write a program named InternetCharge_YourLastName that do the following: ... per month unlimited access is provided. Write a program named InternetCharge
named parameters vs postional parameters - Hibernate
named parameters vs postional parameters  hi,Can you please explain why we i should go for particular parameters or positional parameter... regards, somasekhar
Hibernate Named HQL using XML Mapping
In this section, you will learn executing Named HQL written in XML Mapping file
Create Thread by Extending Thread
Create Thread by Extending Thread This section explain how to create thread by extending Thread class in java. Extending Thread : You can create thread... Thread class to create thread. class ThreadClass extends Thread
Hibernate create POJO classes
Hibernate create POJO classes In this tutorial you will learn how to create a POJO class in Hibernate. POJO (Plain Old Java Object) is a programming model...) to create a classes that implements the entities of the business problem. These can
Create Scale in SWT
Create Scale in SWT       In this section, you will study how to create scale. In order to create the scale, SWT provides the class Scale of package org.eclipse.swt.widgets.
Creating Bean Class In JSF using NetBeans
illustrates how to create the Bean Class. This is also called the Backing Bean... steps are used to create the bean class in the JSF application:-   Step1... for you to modify the class. Here is a Bean Class named LoginForm.java, which
Creating Web application on tomcat server
named as HelloWorld that extends the abstract HttpServlet class. The code written... Create your first Tomcat Web application       In this section we will show you how to create first web
This is a versatile shade of blue named Turquoise.
:5px 0px 5px 5px; } This is a versatile shade of blue named Turquoise. Here
Create Radio Buttons in SWT
, the style RADIO defined in the Button class allows to create radio button. We have create an array object of Button class. The class Label displays... Create Radio Buttons in SWT   
How to Create CurveDraw In Java
: Define class named CurveDraw, for creating  this component. ... How to Create CurveDraw In Java       Introduction In this section, you will learn how to create
Create a ToolBar
Create a ToolBar       This section illustrates you how to create a ToolBar in SWT. To create a ToolBar , we have used the class ToolBar. The method setBounds() sets the size
GetKeepAlive
on the method for creating the Socket() method. Firstly create a class named of  "getKeepAlive" and initialize a class Socket. The main purpose...*; publicclassgetKeepAlive{ publicstaticfinalshortTIME_PORT=135; public
Java Create Directory Example
Java Create Directory Example To create a directory in java call the mkdir() method of java.io.File class. The mkdir() will create the single directry... java.io.*; public class JavaWriteToAFileDirectoryExample{ public static void
Immutable Image using Canvas Class
to create the immutable image using canvas. In this example ImageCanvas class extends the Canvas class to create the immutable image. In the constructor of ImageCanvas class we are trying to create the image and create a exit class as below
Java Thread class
Java Thread Class is a piece of the program execution Java has... It is created by extending the Thread class or implementing Runnable interface Java Thread Class Example public class thread1 extends Thread { @Override
Create new file in java
Create new file in java We are going to discuss how to create new file in java. First of all we have create class "CreateFile".and after that we.... With File class we create files and directories. Java File represents actual
class file
class file  How to create class file in jsf easily
.class and .tld
.class and .tld  how to create .class and .tld file
Advertisements
 

 

 

DMCA.com