Você está na página 1de 3

MUTATOR:-they are the methods which can change the instance field.

ACCESSOR:-they are the methods which cannot change the instance field. WORKHORSE CLASSES:-do not have a main method.

This will not set the values of instance fields. public Employee(String n, double s, . . .) { String name = n; // ERROR double salary = s; // ERROR ... } This will set the instance fields. public Employee(String n, double s, . . .) { name = n; salary = s; ... } implicit and explicit parameters Explicit:-which are inside parentheses, they are listed in method declaration Implicit:-before method name i.e. objects they doesn't appear in method declaration.

A method can access the private member of all objects. Uses a :- (DEPENDANCE) when a sub class uses a super class. Has a :- (AGGREGATION) object of class a contains object of class b. Is-a FINAL:-once an instance variable is defined under this tag it cannot be changed. STATIC:-Any changes are applicable globally i.e. it would be changed in all objects. CONSTANTS:-Any instance variable defined under this category can be called directly without the help of object class.instance variable.

FACTORY METHODS:-these are the static methods used to generate an object of the same class. More than one class in a program can have main method but we can execute one of them only and rest of them will act as they are not present. Java always uses call by value method i.e. it cannot modify the original variable. (Only for primitive types i.e. numbers or Boolean). If we pass the object reference as an explicit parameter then the change would be in original object also. As they refer to the same object. It is not call by reference. public static void tripleSalary(Employee x) // works { x.raiseSalary(200); } you call harry = new Employee(. . .); tripleSalary(harry); Harry and x will refer to the same object. A method can only change the state of the object parameter it cannot insist the object parameter to refer to a different object i.e. we can only change the values. Overloading:-It is for both constructor and methods in this the name of two or more methods is same but they differ in either no. of parameter (method signature) or type of parameter (method signature) or both this is how compiler can differentiate them if no. of parameters as well as type of all parameters are same then it would be a run time error. Return types are not the method signature. If you dont set an explicit parameter in a constructor then it is automatically set to a default value. Zero to numbers false to Boolean and null to objects. We can avoid import statement by writing full package name i.e. java.utill.time we dont have to import java.utill package. We can also use jar utility to store classes to an archive to reduce the space used and it also reduces the access time.

INHERITANCE The idea behind inheritance is that you can create new classes from existing classes. It increases reusability of the methods/fields. To call the methods of super class use super.method() syntax as simple method() wont work in the sub class. The sub class can not use the private fields of the super class so it must be initialized in the sub class through the constructor of the sub class. super (parameters) in the first line of the constructor. Inheritance may be multilevel the collection of all classes extending from a common super class makes an inheritance hierarchy. Any path from any sub class to its super class makes an inheritance chain.

Você também pode gostar