superclass java example

Solutions on MaxInterview for superclass java example by the best coders in the world

showing results for - "superclass java example"
Gianluca
16 Nov 2019
1// Computer.Java Ths is the Super class from whch laptops and Desktops will inherit the attributes of this class
2public abstract class ComputerObject {
3	//Here we declare all of the superclass variables that will be used by both Laptops and desktops
4	//These are attributes of all computers
5	private int usefulLife = 1; 
6	private String stockCode = "XXXXXXXX";
7	private int purchasingCost = 10000;
8	private String staffNumber = "XXXXXXXX";
9	private String serialNumber = "ABCDEFG";
10	private String cpuType = "Multicore Parallel Threading";
11	private int ramAmount = 12;
12	  
13	/**Default construct Need only be present and we do not need any additional constructors except the one below*/
14	 protected ComputerObject() { }
15	 
16	/**Construct a full Computer object. We receive all of the variable information and place them in the correct private variables using our mutators*/
17    /* we use mutators because validation is often done in mutators*/	
18	protected ComputerObject(int usefulLife, String stockCode,int purchasingCost,String staffNumber,String serialNumber ,String cpuType, int ramAmount) { 
19		setUsfulLife(usefulLife);
20		setPurchasingCost(purchasingCost);
21		setRamAmount(ramAmount);
22		setStockCode(stockCode);
23		setStaffNumber(staffNumber);
24		setCpuType(cpuType);
25		setSerialNumber(serialNumber);
26	}
27	 
28	/**Getter/Accessor method for usefulLife*/ 
29	public int getUsfulLife(){
30		return usefulLife; 
31	 }
32	 
33
34	/**Setter/Mutator method for usefulLife*/ 
35	public void setUsfulLife(int usefulLife){
36		this.usefulLife = usefulLife;
37	 } 
38	 /**Getter/Accessor method for purchasingCost*/ 
39	 public int getPurchasingCost(){
40		return purchasingCost; 
41	 }
42	 
43	/**Setter/Mutator method for purchasingCost*/ 
44	public void setPurchasingCost(int purchasingCost){
45		this.purchasingCost = purchasingCost;
46	 } 
47	 
48	 /**Getter/Accessor method for ramAmount*/ 
49	 public int getRamAmount(){
50		return ramAmount; 
51	 }
52	 
53	/**Setter/Mutator method for ramAmount*/ 
54	public void setRamAmount(int ramAmount){
55		this.ramAmount = ramAmount;
56	 } 
57	 
58	 
59	 /**Getter/Accessor method for stockCode*/ 
60	public String getStockCode(){
61		return stockCode; 
62	 }
63	 
64	/**Setter/Mutator method for stockCode*/ 
65	public void setStockCode(String stockCode){
66		this.stockCode = stockCode; 
67	 } 
68	 
69	 
70	  /**Getter/Accessor method for staffNumber*/ 
71	public String getStaffNumber(){
72		return staffNumber; 
73	 }
74	 
75	/**Setter/Mutator method for staffNumber*/ 
76	public void setStaffNumber(String staffNumber){
77		this.staffNumber = staffNumber ;
78	 } 
79
80	 /**Getter/Accessor method for cpuType*/ 
81	public String getCpuType(){
82		return cpuType; 
83	 }
84	 
85	/**Setter/Mutator method for cpuType*/ 
86	public void setCpuType(String cpuType){
87		this.cpuType = cpuType ;
88	 } 
89	 
90	 
91	 
92	  /**Getter/Accessor method for serialNumber*/ 
93	public String getSerialNumber(){
94		return serialNumber; 
95	 }
96	 
97	/**Setter/Mutator method for serialNumber*/ 
98	public void setSerialNumber(String serialNumber){
99		this.serialNumber = serialNumber ;
100	 } 
101	 
102	/**Abstract method AnnualDepreciation*/ 
103	//The implimentations of this method can be found in the Laptop and Desktop sub classes
104	public abstract double AnnualDepreciation(); 
105}
106
107
queries leading to this page
which is the superclass of all java classes 3fdo i use super 28 29 when creating a subclass only in javajava super classaccess function of super class in javasuperclass javabuilding a subclass from a superclass javasuperclass in javasuper class or subclass example in javawhat is a super class in javajava access superclass methodjava subclass method use super definitionjava super keyword calling classhow to set up a super class sub class javahow to call super class in javacall superclass method javajabva calling super classsuper class in javajava subclass call superclasssuperclass subclass javashould you call the super when making a class in javacaller super class method javajava call constructor of super superclasshow to access super class method in javado i use super 28 29 when creating a subclass only n javajava how to make a super classjava program to show the use of super classcall superclass method in subclass javasuper class constructor in javawhat is super class in javais super class is base class in javajava superclass use super class method javasample java program using super and subclass keywordjava super classesjava super class examplewhat is superclass in javawhat is superclass and subclass in javasuper class in java is calledexample of super 28 29 in javajava classes with superclassesaccess a function in rhe super class of a java classwhat is super in java classgood examples of super and sub classes in javainvoking a super a class in javasubclass 2c superclass javasuper class javajava subclass supercalling super class method in javajava super calling classaccessing subclass methods from superclass in javacan you oly have one superclass in javacreate object of super class using subclass in javawhy we say object as a super class in javahow to access subclass methods from superclass in javajava constructor with superclassjava syntax calling a superclass functionaccessing superclass methods from subclass in javasubclass and superclass in javahow to use superclass constructor in subclass javacreate superclass javaho to make class super javahow to use a superclass javahow to use super class in javawhat are subclasses of person super class javahow to call super class method in subclass in javajava class that uses supercreate subclass from superclass javahow to inherit from super class javajava call superclass methodsuperclass java example