300+ TOP Sap Object Oriented Abap Interview Questions and Answers

Q1. Can We Declare Events In Interface In Ooabap ?

Yes, we can declare events in interface in Object Oriented ABAP

Q2. What Is Me Variable?

It just like a self­reference, by this we can call methods that are with in same class with out creating object.

Q3. What Is The Difference In An Instance Method And A Static Method?

Instance method is available separately in each object (instance), static method is global and no instance is required for static method.

Q4. Can We Instantiate Abstract Class In Ooabap ?

  • we cannot create an object to the abstract class instead create an object to the child class and call the methods .
  • Abstract class are mainly used for creating inheritance.

Q5. How To Declare And Raise Events In Ooabap ?

We need to follow below steps when working with events in Object Oriented ABAP:

  • Define an event
  • Define a method
  • Link event and method and convert the method into event-handler method
  • Create a triggering method which will raise the event
  • Use set handler and register event handler method to a particular instance in the program

Q6. Is It Mandatory To Implement All Methods Of Interface In The Class Which Includes Interface?

No it is not mandatory to implement all normal interface methods but it is mandatory to implement all Abstract methods.

Q7. How To Call A Method?

Call method ref­>method_name .

Q8. What Is The Difference Between Function Group And Classes?

We can create many instances of the same class with in a program, but we cannot create many instances of function group.

Q9. What Are The Differences Local & Global Classes?

  • Local classes are defined locally with in a program and the other programs can’t access the same classes directly.
  • But global classes are not like that they are globally accessible from ABAP environment.
  • Global classes are centrally defined in a repository. Transaction code for global classes is SE24(class builder).

Q10. Can We Raise Events In Interface?

No, you can not raise events in interface, Because there is no Implementation for the methods. We can create events in interfaces .

Q11. What Are The Types Of Constructor’s In Ooabap ? Explain ?

CONSTRUCTOR’s are special type of methods, constructor method is executed automatically whenever a object is created or instantiated.

  • Constructor: This method is executed automatically whenever object is created, this is used to set default values with respect to instance/object. The name of the constructor method is CONSTRUCTOR.
  • Static Constructor: This method is executed automatically whenever object is created, this is used to set default values globally irrespective of instances/objects.The name of the static constructor is CLASS_ CONSTRUCTOR.

Q12. What Is A Class In Ooabap?

Class is user defined data type which contains methods, events, attributes, interfaces etc.

Q13. What Is A Single-ton Class?

Single-ton class is a class which allows to instantiate once only .

Q14. How To Create A Global Class?

With tcode SE24.

Q15. How To A Create Object For The Class?

Data: ref type ref to .
Create object ref.

Q16. What Is A Polymorphism In Ooabap ?

Polymorphism is a concept by which the same method names will behave differently in different classes i.e each method will have it’s own implementation in different classes but with the same name.

Q17. Can We Instantiate The Interface?

No, we can not instantiate interface using create object keyword.

Q18. What Is A Global Class In Sap ?

Global classes and interfaces are defined in the Class Builder (Transaction SE24) in the ABAP Workbench.All of the ABAP programs in an R/3 System can access the global classes

Q19. What Is An Interface In Ooabap?

Interface is class which contains methods without implementations.

Q20. What Is A Friend Class?

Friend class is a class it can access private components of it’s friends class.

Q21. What Is A Constructor Method In Ooabap ?

  • These are special type of methods
  • constructor method is executed automatically whenever a object is created or instantiated
  • These methods are mainly used to set default values in a class
  • The name of the constructor method is ‘constructor’
  • These methods have only importing parameters
  • There are no exporting parameters

Q22. How Many Types Of Classes Are There In Ooabap?

  • Public class
  • Private class
  • Final class
  • Single­ton class
  • Abstract class
  • Persistent class
  • Friend class

Q23. What Is A Singleton Class In Ooabap ?

Singleton class is a class which allows to instantiate(Create Object) only once .

Q24. Can We Defined A Class Without A Constructor In Ooabap ?

 Yes, class can be created without any constructor. Default constructor will be created when we define a class without constructor.

Q25. What Is Alias?

Instead of specifying full name of interface methods, we can assign it a name which can directly trigger.

Q26. What Is Abstract Method In Ooabap ?

Abstract methods is a method which doesn’t contain any implementation.

Q27. What Are The Advantages Of Oo Alv ?

Some of the main advantages of Object Oriented ALV

  • We have no of events available in the classes when compared to ALV with function modules which gives flexibility for the programmer to develop ALV’S for various scenarios.
  • We can display more than one ALV grid data on a single screen.
  • The ALV grid data is displayed in the form of custom container with which we can control the size of ALV grid Whereas we cannot control the size of the ALV with function Modules.
  • We can also place different UI elements like checkbox, Radiobutton on the same screen in addition ALV grid data.

Q28. What Is The Difference In Attributes Defined In The Public Versus Private Section Of A Class?

Public attributes can be accessed by class, subclasses and other classes where as Private attributes can be accessed by class itself only.

Q29. How To Define A Class Locally?

class definition.
Public section.
Methods: m1 importing p1 type
Exporting p2 type
Changing p3 type
Returning p4 type
Exceptions .
Protected section.
Private section.
Endclass.
Class implementation.
Method m1.­­­­­­
Endmethod.
Endclass

Q30. Can We Make Methods Of Interface As Abstract And Final In Ooabap ?

No we can not make interface methods as abstract or final in Object Oriented ABAP

Q31. What Is An Event In Ooabap ?

Event is a mechanism by which method of one class can raise method of another class, without the hazard of instantiating that class.

Q32. Does Polymorphism Achieved Through Interfaces?

Yes, by using interface concept in SAP ABAP, we can polymorphism

Q33. What Is A Local Class In Sap ?

Local classes are defined in an ABAP program (Transaction SE38) and can only be used in the program in which they are defined.

Q34. What Is The Difference Between Abstract Class And Interface?

Abstract class is a class which contains at least one abstract method( Method without implementation), Abstract class contains methods with implementation and without implementation and we cannot create instance for the abstract class .

  • Abstract class is mainly for inheritance .
  • Interface contains methods without implementation .

Q35. Can We Achieve Multiple Inheritance Using Interfaces?

Yes, by using interface concept in SAP ABAp, we can achieve multiple inheritance

Q36. What Is The Difference Between Singleton And Static Class In Sap Abap ?

Before going to static classes, you should understand static components.

  • Static Components: Static components (static attributes, static events and static methods) exists globally, no need to create object/instance of the class to access them, we can access them by using static component selector => .
  • Static Class: A class that only contains static components and no instance components is referred to as a static class.
  • Singleton Class: It is a class which does not allow you to create multiple instances.

Q37. What Is An Abstract Class In Ooabap ?

  • It is a class which contains methods with implementation as well as methods without implementation .
  • Abstract class is a class which contains at least one abstract method.

Q38. What Is The Use Of ‘defination Deferred’ Keyword In Ooabap ?

It is the keyword which indicates the class definition is delayed or postponed or Defined at some place in program.

Syntax : CLASSÂ Â DEFINITION DEFERED.

Q39. What Is Alias Name In Ooabap?

Alias is an alias name for the interface method implemented in the class .

Q40. How To Create An Object For Private Class?

In general we can not create object for a private class, but we can access static method of a private class so call that method using its class name and import that object.

For example take one static method with an exporting parameter inside private class and write object creation code in that static method and export that object.