Oops concept in AX
Class : Class is the 1st OOPs concept .Class defines the characteristics of objects which includes its attributes , fields properties and behavior . Let us say we have a class called car , then the color , model number , top speed can be its attributes and properties . Accelerating , breaking , turning will be its behavior
Objects: Objects can be considered as a thing that performs a set of related functions .Programming objects are used to model real worlds objects. An object is also an instant of a class . For our class Car , Ferrari will be our object
Instance : One can have an instance of a class; the instance is the actual object created at runtime. The set of values of the attributes of a particular object is called its state. The object consists of state and the behaviour that’s defined in the object’s class.
Method :Also called as functions in some programming languages , methods defines the behavior of particular objects . For our Car class , turning() , breaking () will be our methods .
Inheritance : a parent class can inherit its behavior and state to children classes. This concept was developed to manage generalization and specialization in OOP .Lets say we have a class called Car and Racing Car . Then the attributes like engine no. , color of the Class car can be inherited by the class Racing Car . The class Car will be Parent class , and the class Racing Car will be the derived class or child class
Abstraction : representing only the important details without including all the details . For example the car Ferrari can be treated as simple car only .
Encapsulation:The wrapping up of data and functions into a single unit is called as encapsulation . For example the class car has a method turn () .The code for the turn() defines how the turn will occur . So we don’t need to define how Mercedes will turn and how the Ferrari will turn separately . turn() can be encapsulated with both.
Polymorphism: Its an important OOPs concept , Polymorphism means taking more than one forms .Polymorphism allows the programmer to treat derived class members just like their parent class’s members. More precisely, Polymorphism in object-oriented programming is the ability of objects belonging to different data types to respond to calls of methods of the same name .If a Dog is commanded to speak(), this may elicit a bark(). However, if a Pig is commanded to speak(), this may elicit an oink(). Each subclass overrides the speak() method inherited from the parent class Animal.
Objects: Objects can be considered as a thing that performs a set of related functions .Programming objects are used to model real worlds objects. An object is also an instant of a class . For our class Car , Ferrari will be our object
Instance : One can have an instance of a class; the instance is the actual object created at runtime. The set of values of the attributes of a particular object is called its state. The object consists of state and the behaviour that’s defined in the object’s class.
Method :Also called as functions in some programming languages , methods defines the behavior of particular objects . For our Car class , turning() , breaking () will be our methods .
Inheritance : a parent class can inherit its behavior and state to children classes. This concept was developed to manage generalization and specialization in OOP .Lets say we have a class called Car and Racing Car . Then the attributes like engine no. , color of the Class car can be inherited by the class Racing Car . The class Car will be Parent class , and the class Racing Car will be the derived class or child class
Abstraction : representing only the important details without including all the details . For example the car Ferrari can be treated as simple car only .
Encapsulation:The wrapping up of data and functions into a single unit is called as encapsulation . For example the class car has a method turn () .The code for the turn() defines how the turn will occur . So we don’t need to define how Mercedes will turn and how the Ferrari will turn separately . turn() can be encapsulated with both.
Polymorphism: Its an important OOPs concept , Polymorphism means taking more than one forms .Polymorphism allows the programmer to treat derived class members just like their parent class’s members. More precisely, Polymorphism in object-oriented programming is the ability of objects belonging to different data types to respond to calls of methods of the same name .If a Dog is commanded to speak(), this may elicit a bark(). However, if a Pig is commanded to speak(), this may elicit an oink(). Each subclass overrides the speak() method inherited from the parent class Animal.
Difference between method overriding and overloading
This is a discussion on Difference between method overriding and overloading within the OOPS forum
Overriding is the concept of having functions of same name and signature in different classes. one in the super class can be made virtual and other can override the functionality of virtual one.
Overloading is the concept of having functions of same name, but different signature in same class. They are differentiated by the compiler by their signatures.
Overloading is the concept of having functions of same name, but different signature in same class. They are differentiated by the compiler by their signatures.
Overloading methods
1.They appear in the same class or a subclass
2.They have the same name but, have different parameter lists, and can have different return types.
Overriding methods
It allows a subclass to re-define a method it inherits from it's superclass
overriding methods:
1. It appears in subclasses
2. They have the same name as a superclass method
3. They have the same parameter list as a superclass method
4. They have the same return type as as a superclass method
5. They have the access modifier for the overriding method may not be more restrictive than the access modifier of the superclass method
1.They appear in the same class or a subclass
2.They have the same name but, have different parameter lists, and can have different return types.
Overriding methods
It allows a subclass to re-define a method it inherits from it's superclass
overriding methods:
1. It appears in subclasses
2. They have the same name as a superclass method
3. They have the same parameter list as a superclass method
4. They have the same return type as as a superclass method
5. They have the access modifier for the overriding method may not be more restrictive than the access modifier of the superclass method
·If the superclass method is public, the overriding method must be public
·If the superclass method is protected, the overriding method may be protected or public
·If the superclass method is package, the overriding method may be packagage, protected, or public
·If the superclass methods is private, it is not inherited and overriding is not an issue
In method overloading means one method can callto diffrent sub class of base class and in method overriding method in subclass takes priority over it's counterpart.
More about.....OOPs Concept
ReplyDeleteLing
Thanks for one marvelous posting! I enjoyed reading it; you are a great author. I will make sure to bookmark your blog and may come back someday. I want to encourage that you continue your great posts, have a nice weekend!
ReplyDeleteSurya Informatics
Its very easy for understanding. Very good explanation. Thank you for sharing.
ReplyDeleteMS Dynamics Trade and Logistics Online Training