Home Answers Viewqa Java-Beginners create named class

 
 


zam
create named class
0 Answer(s)      3 years and 5 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?
View Answers









Related Pages:
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
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
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
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
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="
create a class
create a class  plz provide any example related to class
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" /> <
Hibernate Named HQL in Annotation
In this section, you will learn how to execute Named HQL written in Model class Annotation
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
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
JPA Named Query
Class: JPANamedQuery.java Database Table: student CREATE TABLE... JPA Named Query      ... and how to use the JPA Named Query in your JPA application. JPA Query is powerful
Hibernate Named Native SQL in Annotation
In this section, you will learn how to execute the Named Native SQL written in Model class Annotation
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
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
USER DEFINED CLASS
Create a java program for a class named MyDate that contains data members and a constructor that meet the criteria in the following list. This class is used... Create a java program for the class MyDate, and call the new class MyDate2
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
Java Class Question?
the user enters a selection. Create a class named TVShow.java. Data Fields can...Java Class Question?  Write an application that prompts the user... fields. Create a UseTVShow.java file that prompts the user to input up to 5 TV
Class Average Program
of all  we have to define class named "AverageExample". To calculate... Class Average Program       This is a simple program of Java class. In this tutorial we
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
Class level access
be accessed on class level means no need to create object to use classShow() method. We... Class level access       Objective-C provides facility of class level access
Java class in JSP
the jsp page we now need to create an object of the class by using the new operator.... To perform this example we need to create a java class. In this example we are making a class named as DateDemo inside a package. Declare one method named
how i want to create a coding by this question?
how i want to create a coding by this question?  Design and write a class named Person and its two subclasses named Student and Employee. Make... or year 3). An employee has a department, salary and date hired. Define a class
PHP Class Object
: In the above programming we create a class named A, it has a publically...PHP Class Object: In object oriented programming a class can be an abstract data type, blue print or template. You could consider the name of a class as noun
Class
a class, it can be used to create objects by instantiating the class. Each... class "Classtest" and also create a class "Example" which... create a class object "myExample" of class "Example" and call
JDBC : Create Database Example
JDBC : Create Database Example In this section you will learn how to create database using JDBC with example. Create Database : Database is an organized... the driver. DriverManager  :  The DriverManager class will attempt to load
JDBC: Create Table Example
are creating table, named student in the database. For that we create...JDBC: Create Table Example In this section, we are going to create table using JDBC and using database MySql. Create Table : Database table is collection
Create Array ??
Implementation -Create a class called â??PhoneEntryâ?? which can be used to store the name and number of ONE client. -Create a class called â??MyArrayListâ?? which...?¦ . -Create an appropriate interface that use the class â??MyLinkedListâ
.class and .tld
.class and .tld  how to create .class and .tld file
class file
class file  How to create class file in jsf easily
Inner-class Listeners
Java NotesInner-class Listeners Named inner class Defining an inner class listener to handle events is a very popular style. Access. Use an inner class.../SomePanel.java // Purpose: Show use of named inner class listener. // Author : Fred
How to create CheckBox On frame
: There is class named CheckBox is used in the program for creating a checkbox component... How to create CheckBox On frame     ... will learn how to create CheckBox on the frame. In the Java AWT, top-level windows
missing some import class(may be) - Java Beginners
on the class name"class shape is public,should be declared in a file named.... For example you have to create a class "shape" then create new file in netbeans...missing some import class(may be)  Hi,Experts,I am a new one. I have
Matrix Class
Matrix Class   A class to manage matrices and add them. Create in the driver class two objects of it and use the add method
Matrix Class
Matrix Class   A class to manage matrices and add them. Create in the driver class two objects of it and use the add method
How To Create Internal Frames In Java
. In the second method named createInternalFrameGUI we will create multiple...How To Create Internal Frames In Java In this tutorial we will learn about how to create a frame within a frame. Some times you will need to display a frame
create dao
create dao  code 1 package com.dao; import java.sql.*; import com.beans.*; public class DbAccess { public void createStudent(SampleBean...) { System.out.println("Error in create access"); } } public SampleBean
java class
java class  write a java program to display a msg "window closing" when the user attempts to close the window.(a) create a window class (b) create frame within the window class (c) extends window adapter class to display the msg
java class
. a. Create a window class. b. Create frame within the window class. c. Extend WindowAdapter class to display the message â??Window Closingâ... send according of java class assoon as possible . Write a java program to display
Request[/searchMenu] does not contain handler parameter named 'function'. This may be caused by whitespace in the label text. - Subversion
Request[/searchMenu] does not contain handler parameter named 'function... struts DispatchAction class .i am facing error like Request[/searchMenu] does not contain handler parameter named 'function'. This may be caused by whitespace
Hibernate named queries
Hibernate named queries  Hi, What is named queries in Hibernate? Thanks
Create and Save Excel File in JSP
. The java.io.InputStream class is used to create file. We are creating an excel file... HSSFWorkbook class is used to create an object of  HSSFWorkbook, by which we... to create a new sheet. This class is used to create a high level worksheet
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
Class Loader
a file of that name from the file system. Class loader does not create class object...Class Loader  What is class loader? Explain in detail.   The Java ClassLoader is a an abstract class which extends the Object class. Java
Class Loader
a file of that name from the file system. Class loader does not create class object...Class Loader  What is class loader? Explain in detail.   The Java ClassLoader is a an abstract class which extends the Object class. Java