Interview questions for OOPS in ABAP.

 1. What is OOPS.

* Object oriented programming language.

* The entire program is visualized in terms of class & objects

* It takes very less time to enhance the existing functionality.


2. What is class and Object.

* Class.

- Blue print of an object.

- Collection of data members and member functions.

- There are 2 types.

  Local class

* Local class name starts with any letter.

* Created in SE38.

* Access within the program only.

  Global class

* Global class name starts with 'Y' or 'Z'.

* Created in SE24.

* We can access the global class from anywhere in SAP.

- Class contains

   * Class Definition.

   * Class implementation.

* Object

- Object is the real one.

- Instance of class.


3. What is attribute.

* Attributes are used to declare the variables, work areas, internal tables which are needed to implement the logics.


4. What is method?

* It is a collection of statements which perform the particular activity.


5. What is Events?

* Event is an action which is performed at run time. 

* Events are used to provide the dynamic features at run time.

* Events are used to handle the methods of some other class.


6. What is interface?

* Interface is the collection of methods which are defined & not implemented.


7. What are visibility sections and types.

* Public 

    - We can access the public components within the class as well as outside the class.

* Protected section

    - We can access the protected components within the class as well as derived or child class.

* Private section

    - We can access the private components within the class only.

* In ABAP we haven't default visibility section.


8. What is class definition and class implementation.

* Class definition

- Class definition is nothing but declaring the all the components of the class & any one of the visibility sections.

* Class implementation

- Class implementation is nothing but implementing the methods which are defined in the class definition.


9. What is static and instance in OOPS.

static 

                * Single copy of object.

                Create static attribute --> class-data: st_attr type i.

                *  Create static method --> class-methods st_method.

                * Static attribute accessed using class & object.

                            class_2 => st_method( ).

instance 

                * Multiple copies depend on the instances/objects.

        * Create instance attribute --> data: ins_attr type i

        * Create instance method -->methods: ins_method.

                * Instance attribute accessed only using object.

                           obj-> st_method( ).

** call method within method - me->ins_method( ).


10. What is constructor?

* Constructor is a special method to initialize the attributes at runtime. 

* Constructor contains two types. 

* They are Instance constructor and Static Constructor.


11. Differences between Normal methods and Constructors.

* Normal methods

- Can be declared in any sections.

- Should be called explicitly.

- Can be called any no of times using same object.

- Contain any type of parameters ( Import,Export,Changing,Returning).

- Can return any number of values

* Constructor

- Can be declared in public sections.

- Should be called implicitly.

- Instance - called only once in lifetime of object

           Static - Called only once in lifetime of class.

- Instance - import, static - no parameters

- Never return values.


12. What is inheritance?

* One class get the properties of another class.

* The sub class can access the all the components of super class which are defined under public or protected section only not under the private section. 

* Through super class object we can access the components of the super class only. 

* Through sub class object we can access the components of sub class as well as super class also.


13. What are different types of inheritances?

* Single.

* Multiple.

* Multilevel.

* Actually, Multiple inheritance isn't possible. 

  If we want Multiple Inheritance, then we can do through interfaces only. 

          Directly it's not possible.


14. What is method overloading and method overriding?

* Method Overriding

- Method overriding means We can declare one method in super class. 

   we have some values in this method 

    I'm using method redefinition in the sub class

      in sub class I'm giving the different values

        at the time of calling the method from subclass object,

          it'll display the values which are defined in the subclass method.

* Method Over loading

- Method over loading means a class can contain more than one method 

  with same name and different variables, 

  it's called as method overloading. 

- But ABAP doesn't support Over loading.


15. What is abstract in OOPS?

* A class which contain at least one or more than one abstract method then it's called as Abstract class. 

* These are used to define some common functionalities in 

  Abstract class (Super-class) and those can be used in derived classes (Sub classes).


16. What is interface?

* Interface is the collection of Methods which are defined but not implemented. 

* These all are implemented through another class.


17. Differences between Abstarct class and interfaces?

* Abstract class.

- Can contain both abstract and non-abstract methods.

- Explicitly needs to declare the method as 'abstract'.

- Declared in public and protected sections.

- Class can inherit only one abstract class.

* Interfaces

- Only abstract methods.

- By default, all the methods are 'abstract'.

- By default, all the components of interface are public.

- Class can implement any no of interfaces.


18. What is encapsulation and polymorphism.

* Encapsulation

- Binding or wrapping the code and data in a single unit is called Encapsulation. 

- CLASS is the best example for the Encapsulation. 

- In a class we can write methods, events, variables all as single unit. 

- So, Class is the best example for Encapsulation.

* Polymorphism

- A single entity or method behaves in multiple forms then it's called Polymorphism. 

- For example, take VBELN

    it acts as Sales document number in VBAK table

     it acts as Delivery number in LIKP table

       it acts as billing number in VBRK table 

         VBELN is only one variable act as 3 types in 3 different tables.

19. What is exceptions?

* Exceptions

- Exception is nothing but run time error. 

- We handle these exceptions by using TRY & CATCH blocks.


Comments

Popular posts from this blog

New syntax for append- VALUE (new syntax 7.4+) in ABAP

Read statement new syntax in ABAP. (7.4+).

Concatenation new syntax( 7.4+ ).