Category - big ass
In java, abstraction is achieved using abstract classes and interfaces. A class which contains the abstract keyword in its declaration is known as abstract class. Abstract public class interfacea abstract public void interfacemethod() the only difference is that the second way doesnt let the compiler know that its actually an interface. This can be useful if you want people to only implement your interface and no others. Data abstraction is the process of hiding certain details and showing only essential information to the user. Abstraction can be achieved with either abstract classes or interfaces (which you will learn more about in the next chapter). The abstract keyword is a non-access modifier, used for classes and methods. Java abstract class is used to provide common method implementation to all the subclasses or to provide default implementation. We can run abstract class in java like any other class if it has main() method. If i missed anything important, please let us know through comments. I am trying to use an abstract class employee which has two subclasses, hourlyemployee and annualemployee. In c you cannot define abstract fields, even in an abstract class. You can, however, define abstract properties as these are effectively methods (e. As some have reminded, you should never have public fieldsvariables in your classes, even in c.). Now lets go through the code abstract class employee - employee is an abstract class as abstract modifier is used. Since, employee is an abstract class so, there must be an abstract method in it. Abstract int getsalary() - notice that its body is left empty to be defined in the subclass and abstract keyword is also used here. Unlike a regular java class, an abstract class may not only contain the regular methods, defined with curly braces but may also contain the abstract methods, ending with a semicolon or a mix of regular and abstract methods.