1 / 4

ABSTRACT CLASSES

ABSTRACT CLASSES. IHTESHAM UL HAQ. ABSTRACT CLASSES. Abstract classes are kinds of classes which cannot be instantiated. Means we cannot create an object of the class. But what we can do is to create certain variables and methods which might not be empty.

Télécharger la présentation

ABSTRACT CLASSES

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ABSTRACT CLASSES IHTESHAM UL HAQ

  2. ABSTRACT CLASSES • Abstract classes are kinds of classes which cannot be instantiated. • Means we cannot create an object of the class. • But what we can do is to create certain variables and methods which might not be empty. • Abstract classes can then be inherited or extended in the same way as other classes can be inherited. • Abstract classes can be used as a main parent for some kind of a group of objects. • Abstract classes provide a default method for us means if we want to use some pre-defined method for us, it can be used. • We can then create an object of its child class.

  3. ABSTRACT CLASSES

  4. ABSTRACT CLASSES • Declaring an Abstract Class //Parent.java public abstract class Parent{ public int x= 19; public void welcome(){ ………………………………….. } public int result(){ …………………………….. } public String hello(){ ……………………………….. } } //AChild.java public class AChild extends Parent{ ……………….. } child //Runit.java public class Runit{ Parent p = new Paerent(); } If we now create an object of the abstract Class it wont , it will give an error. //Runit.java public class Runit{ AChild ac = new AChild(); } Now this will work

More Related