Salesforce Interview Questions on Apex
1. What are the Oop's Concepts in Apex Programming?
OOPs Concepts in Salesforce
OOPs Concepts:
OOPs have 4 types of features.
1) Encapsulation
2) Inheritance
3) Polymorphism
4) Abstraction
Encapsulation: Encapsulation is an Object Oriented Programming concept that binds together the data and functions that manipulate the data, and that keeps both safe from outside interface and misuse. Data Encapsulation led to the important OOP concept of data hiding.
It is all about hiding the code to secure the contacts of a program. To hide the code we enclose the members of a program under a container or wrapper as class.
Simply
*** Binding of/wrapping up of programming elements into a single unit is called Encapsulation.
Ex: class and interfaces.
Class classname {
//Binding elements in class
}
Class:
Class is a able to print of real world existence.
Class is a collection of variables and methods.
Class is user defined data types.
Inheritance: Acquiring the properties of parents by children is what we call as Inheritance. We can make use of the same principle under object oriented language and consume the members of one class under multiple classes by establishing Parent-Child relationship between classes. This basically provides us Reusability.
Simply
***Reasonability of programming elements from one class to another class with the help of ‘Extends’ keyword.
Ex:-
Abstract/Virtual class A {
//Variables
//Methods
}
Class B extends A {
}
Polymorphism: Changing the behavior of entities depending upon input they receive is known as Polymorphism. This can be implemented in object oriented language using different approaches like
-Overloading: It is a feature that allows us to define multiple behaviors to a method.
-Overriding: To override parent classes’ method under child class first in the parent class the method must be declared as Virtual. Then only child classes can override the method using override modifier.
Simply
More than one method having same name but parents are different.
- Method overloading
- Method overriding
Abstraction: This all about hiding the complexity of a program and providing with a set of interface to consume the functionalities. Functions and Methods example for Abstraction we never know the logic behind them.
Simply
Level of hiding the programming elements after encapsulation.
It has 4 Access Specifies
- Private
- Public
- Protected
- Global
0 Comments