Sie sind auf Seite 1von 3

JAVA

Abstraction- Data abstraction is the reduction of a particular body of data to a simplified representation of the whole. Abstraction,
in general, is the process of taking away or removing characteristics from something in order to reduce it to a set of essential
characteristics.
Encapsulation- Data encapsulation sometimes referred to as data hiding, is the mechanism whereby the implementation details of
a class are kept hidden from the user. The user can only perform a restricted set of operations on the hidden members of the class
by executing special functions commonly called methods.
Inheritance- Inheritance refers to a feature of Java programming that lets you create classes that are derived from other classes. A
class that's based on another class inherits the other class. The class that is inherited is the parent class, the base class, or the
superclass.
Polymorphism- Polymorphism is the ability of an object to take on many forms. The most common use of polymorphism in OOP
occurs when a parent class reference is used to refer to a child class object. Any Java object that can pass more than one IS-A test is
considered to be polymorphic.
Implementing Inheritance-
Excepting Object, which has no superclass,
every class has one and only one direct
superclass (single inheritance). In the
absence of any other explicit superclass,
every class is implicitly a subclass
of Object. Classes can be derived from
classes that are derived from classes that
are derived from classes, and so on, and
ultimately derived from the topmost
class, Object. Such a class is said to
be descended from all the classes in the
inheritance chain stretching back
to Object.

The idea of inheritance is simple but powerful: When you want to create a new class and there is already a class that includes some
of the code that you want, you can derive your new class from the existing class. In doing this, you can reuse the fields and methods
of the existing class without having to write (and debug!) them yourself. A subclass inherits all the members (fields, methods, and
nested classes) from its superclass. Constructors are not members, so they are not inherited by subclasses, but the constructor of
the superclass can be invoked from the subclass.
Developing polymorphism
Static Polymorphism: It is achieved through function overloading and operator overloading. It is always faster. It is also called as
compile time polymorphism. Example of static polymorphism is method overriding using final or private methods. At the
compilation time java knows which method is call by checking the arguments, so it is also known as early binding or static binding.

Types of static polymorphism :

1. Function Overloading: It is nothing but the ability of one function performs different tasks. These functions must
differ by the data types. To call function the same function name is used for various instances.
2. Operator Overloading: Java does not support operator overloading.

Dynamic Polymorphism : It is also called as run-time polymorphism. In this case java compiler does not know which method is
invoked at compilation time. Just JVM decides which method is invoked at the run-time. Method overriding is example of run-time
polymorphism. In this case overridden method is invoking through the super class reference variable.

Types of Dynamic Polymorphism in java:


Virtual Function: This is nothing but the function whose performance can be overridden within an inheriting class by a
function with the same argument or signature. Virtual function cannot be declared as private. In this function we get
warning if we do not use Virtual or New keyword. You can use new keyword rather than Virtual.
Subclass, Superclass, Inherit class-

1. A Java subclass is a class which inherits a method or methods from a Java superclass.
2. The derived class (the class that is derived from another class) is called a subclass. The class from which it's derived is
called the superclass. The following figure illustrates these two types of classes: In fact, in Java, all classes must be
derived from some class.
3. A derived class or inherit class is a class created or derived from another existing class. The existing class from which
the derived class is created through the process of inheritance is known as a base class or superclass.

Application program for:

Employee.Java Salary.Java
* Exercise 3.14 - Employee Class
* This Program Calculates The Yearly Salary Of Employees
*
*/

public class Employee {

private String firstName;


private String lastName;
private double monthlySalary;

public Employee(String name, String name2, double salary) {


firstName = name;
lastName = name2;
monthlySalary = salary;
}

public void setFirstName(String name) {


firstName = name;
}

public String getFirstName() {


return firstName;
}

public void setLastName(String name) {


lastName = name;
}

public String getLastName() {


return lastName;
}

public void setmonthlySalary(double salary) {


monthlySalary = salary;
}

public double getmonthlySalary() {


return monthlySalary;
}

public double yearlySalary() {


double yearlySalary;
yearlySalary = (monthlySalary * 12);
return yearlySalary;
}

public double yearlySalaryIncrease() {


double yearlySalaryIncrease;
yearlySalaryIncrease = (((yearlySalary() * (0.1)) + yearlySalary()));
return yearlySalaryIncrease;
}

public void displayYearlySalary() {


System.out.printf("%s %s's Yearly Salary is $%.2f\n", firstName, lastName,
yearlySalary());
}

public void displayYearlySalaryIncrease() {


System.out.printf("%s %s = $%.2f\n", firstName, lastName,
yearlySalaryIncrease());
}

}
ASP.NET
Adding View/ View data

1. Right click on the Views folder, and then Add > New Folder and name the folder HelloWorld.
2. Right click on the Views/HelloWorld folder, and then Add > New Item.
3. In the Add New Item - MvcMovie dialog. In the search box in the upper-right, enter view. Tap MVC View Page.

Changing Views and layout pages

In MVC3 you have _ViewStart.cshtml that stores all pages' Layout; you can change this element to change all pages' Layout or you
can add new Layout element in top of target view pages in @{} block like the following to change the layout of the specific page:

Change the title and menu link in the layout file

Change the contents of the title element. Change the anchor text in the layout template to "Movie App" and the controller
from Home to Movies as highlighted below:

Das könnte Ihnen auch gefallen