oops abap

 oops abap


Q1. What is OOPS ABAP ?

Ans:

  • Object orientation (OO), or to be more precise, object-oriented programming, is a problem-solving method in which the software solution reflects objects in the real world.

  • A comprehensive introduction to object orientation as a whole would go far beyond the limits of this introduction to ABAP Objects. This documentation introduces a selection of terms that are used universally in object orientation and also occur in ABAP Objects. In subsequent sections, it goes on to discuss in more detail how these terms are used in ABAP Objects. The end of this section contains a list of further reading, with a selection of titles about object orientation.
The object-oriented approach focuses on objects that represent abstract or concrete things of the real world. ... These objects are defined by their character and properties that are represented by their internal structure and their attributes (data).


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

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

Q3. What Is An Interface In Ooabap?

Ans: Interface is class which contains methods without implementations.

Q4. Can We Instantiate The Interface?

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

Q5.Can We Achieve Multiple Inheritance Using Interfaces?

Ans: Yes, by using interface concept in SAP ABAP, we can achieve multiple inheritance

Q6. Does Polymorphism Achieved Through Interfaces?

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

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

Ans: 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 .

Interface:

1. Can contain only abstract methods.

2. By default all methods are abstract.

3. All components of interface by default are public.

4. Interface components must be prefixed with the name of the interface.

Abstract Class:

1. Can contain both abstract and non-abstract methods.

2. Explicitly we need to use abstract keyword.

3. Abstract methods can be declared in public or protected section.

4. A class can inherit only one abstract class.

5. Abstract class components are directly referred in subclass.


Q8. What Is Alias Name In Ooabap?

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

Q9. Can We Raise Events In Interface?

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

Q10. What Is A Single-ton Class?

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

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

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

  • The attributes and methods declared in Public section in a class can be accessed by that class and any other class, sub-class of the program.

  • When the attributes and methods are declared in Protected section in a class, those can be accessed by that class and sub classes (derived classes) only.

  • When the attributes and methods are declared in Private section in a class, those can be accessed by only that class and not by any other class.


Q12. What is the Difference between Class and Object ?

Ans: A Class is actually a blueprint or a template to create an Object. Whereas an Object is a an actual instance of a Class. For example Employee is a class, while John is a real employee which is an Object of Employee Class.

Q13. How polymorphism can be implemented ?

Ans: Some examples to implement polymorphism:

  • Method Overriding
  • Method Overloading
  • Operator Overloading

Q14. What is Inheritance ?

Ans: In OOPs terminology, inheritance is a way to form new classes using classes that have already been defined. Inheritance is intended to help reuse existing code with little or no modification. The new classes, known as derived classes, inherit attributes and behavior of the pre-existing classes, which are referred to as base classes.

Q15. What is Method Overriding ?

Ans:

  • Method overriding allows a subclass to override a specific implementation of a method that is already provided by one of its super classes.
  • A subclass can give its own definition of methods but need to have the same signature as the method in its super class. This means that when overriding a method the subclass's method has to have the same name and parameter list as the super class's overridden method.

Q16. What is Method Overloading ?

Ans: Method overloading is in a class have many methods having same name but different parameter called overloading or static polymorphism

Q17. What is Aggregation ?

Ans: Aggregation is a special form of association. Aggregation is the composition of an object out of a set of parts. For example, a car is an aggregation of engine, tyres, brakes, etc.
Aggregation represents a "Has" relationship like a car has a engine.

Q18. What is object oriented programming language ?

Ans: Object oriented programming language allows concepts such as abstraction, modularity, encapsulation, polymorphism and inheritance. Simula is the first object oriented language. Objects are said to be the most important part of object oriented language. Concept revolves around making simulation programs around an object.

Q19. What are the core ABAP oops concepts ?

Ans:

  • Inheritance: Inheritance is the ability of an object to inherit the properties and methods of another object. This characteristic leads to the creation of families of objects (just like families exist for humans) with parent objects and child objects.
  • Polymorphism: Polymorphism is about an objects ability to provide context when methods or operators are called on the object.

Q20. Definition: Polymorphism

Ans: In object-oriented programming, polymorphism (from the Greek meaning "having multiple forms") is the characteristic of being able to assign a different meaning to a particular symbol or "operator" in different contexts. The simple example is two classes that inherit from a common parent and implement the same virtual method.

Q21. Definition: Encapsulation

Ans:

  • Encapsulation: Encapsulation is the ability that an object has to contain and restrict the access to its members. Encapsulation is a key concept of object programming that ensures the autonomy and integrity of the objects.
  • Abstraction: Another OOPS concept related to encapsulation that is less widely used but gaining ground is abstraction.

Q22. Definition: Abstraction

Ans: Through the process of abstraction, a programmer hides all but the relevant data about an object in order to reduce complexity and increase efficiency. In the same way that abstraction sometimes works in art, the object that remains is a representation of the original, with unwanted detail omitted. The resulting object itself can be referred to as an abstraction, meaning a named entity made up of selected attributes and behavior specific to a particular usage of the originating entity.

Q23. What is UML ?

Ans:

  • UML (Unified Modeling Language) is a standardized modeling language. It is used for the specification, construction, visualization and documentation of models for software systems and enables uniform communication between various users.
  • UML does not describe the steps in the object-oriented development process.
  • SAP uses UML as the company-wide standard for object-oriented modeling.
  • UML describes a number of different diagram types in order to represent different views of a system.

Q24. What are the types of Objects and Classes ?

Ans: In general there are two types of Objects: Instance Object and Static Object and as such there are two types of Classes: Instance class and Static Class. Specifically when it comes to visibility, Private class, Protected class and Public classes are the types of classes one can have.

Q25. What are the types of classes which can be created ?

Ans:

  • We can create four types of classes under final and only modeled category(optional) with the private, protected, public and abstract instantiation.
  • Usual Abap Class.
  • Exception Class(With/Without messages).
  • Persistent Class.
  • Test Class(ABAP Unit).

Q26. What are the types of classes which can be created ?

Ans:

  • We can create four types of classes under final and only modeled category(optional) with the private, protected, public and abstract instantiation.
  • Usual Abap Class.
  • Exception Class(With/Without messages).
  • Persistent Class.
  • Test Class(ABAP Unit).

Q27. What is a reference variable ?

Ans: Objects can only be created and addressed using reference variables. Reference variables allow you to create and address objects. Reference variables can be defined in classes, allowing you to access objects from within a class.

Q28. What is a reference variable ?

Ans: Objects can only be created and addressed using reference variables. Reference variables allow you to create and address objects. Reference variables can be defined in classes, allowing you to access objects from within a class.

Q29. What is the difference between Abstract method and a Final method ?

Ans:

  • Abstract method
  • Abstract instance methods are used to specify particular interfaces for subclasses, without having to immediately provide implementation for them. Abstract methods need to be redefined and thereby implemented in the subclass (here you also need to include the corresponding redefinition statement in the DEFINITION part of the subclass). Classes with at least one abstract method are themselves abstract. Static methods and constructors cannot be abstract (they cannot be redefined).
  • Abstract (instance) methods are defined in the class, but not implemented
  • They must be redefined in subclasses.

Q30. What is a super class ? How can it be implemented ?

Ans: A super class is a generalization of its subclasses. The subclass in turn is a specialization of its super classes.

Q31. What is a Narrowing Cast ? How can you implement it ?

Ans: The assignment of a subclass instance to a reference variable of the type "reference to superclass" is described as a narrowing cast, because you are switching from a more detailed view to a one with less detail.

Q32. What is a Widening Cast ?

Ans: The widening cast is, as with inheritance, the opposite of the narrowing cast: Here it is used to retrieve a class reference from an interface reference.

Q33. What is a singleton ?

Ans: If it is to be impossible to instantiate a class more than once (for example, because it serves as a data administrator or data container), you can use the singleton concept. The class is defined with the addition CREATE PRIVATE and FINAL and instantiated using its static constructor. A public static component could then make the reference to the class available to an external user.

Q34. What are the limitations of redefining a method ?

Ans: Inherited methods can be redefined in subclasses Redefined methods must be re-implemented in subclasses. The signature of redefined methods cannot be changed Static methods cannot be redefined. In inheritance, static components are "shared": A class shares its non-private static attributes with all its subclasses. In ABAP Objects, you can not only add new components, but also provide inherited methods with new implementations. This is known as redefinition. You can only redefine (public and protected) instance methods, other components (static methods, attributes and so on) cannot be redefined. Changes to method parameters (signature changes) are not possible.

Q35. What are static components? What is a component selector ?

Ans: In inheritance, static components are "shared": A class shares its non-private static attributes with all its subclasses. => and -> are the component selectors used to refer.

Q36. What are component instance ?

Ans: A component instance is a running component that can be run in parallel with other instances of the same component.

Q37. How is Encapsulation implemented in OOPs ?

Ans: Encapsulation means that the implementation of an object is hidden from other components in the system, so that they cannot make assumptions about the internal status of the object and therefore dependencies on specific implementations do not arise.

Q38. What are BADIs? What are BADI filters ?

Ans: BADI - Business Add Ins are enhancements to the standard version of the code of SAP.
Filter Badi- Business Add-Ins may be implemented on the basis of a filter value. If an enhancement for country-specific versions is provided for in the standard version, it is likely that different partners will want to implement this enhancement. The individual countries can create and activate their own implementation.

Q39. What are the types of Exception classes ?

Ans:

  • Global
  • Local Exceptions Class.

Q40. Where can a protected method be accessed ?

Ans: Protected components Only visible within the class and its sub classes.

Q41. What is a signature of a method ?

Ans:

  • Methods have a parameter interface (called signature ) that enables them to receive values when they are called and pass values back to the calling program.
  • In ABAP Objects, methods can have IMPORTING, EXPORTING, CHANGING, and RETURNING parameters as well as exception parameters.
  • CLASS DEFINITION. ... METHODS: [ IMPORTING TYPE EXPORTING TYPE CHANGING TYPE RETURNING VALUE() TYPE EXCEPTIONS RAISING ]. ENDCLASS.(signature of a method). CLASS IMPLEMENTATION. METHOD . ... ENDMETHOD. ENDCLASS.

Q42. What is a functional Method ?

Ans: Methods that have a RETURNING parameter are described as functional methods. These methods cannot have EXPORTING or CHANGING parameters, but has many (or as few) IMPORTING parameters and exceptions as required.

Q43. What is a de-referenced variable ? What is a garbage collector ?

Ans: To go to an address before performing the operation a dereference variable is a pointer to the variable, not the variable itself. A pointer can be re-assigned any number of times while a reference cannot be reassigned after initialization. Field symbols are similar to dereference pointers. Thus, you can only access the content of the data object to which the field symbol points. (That is, field symbols use value semantics). If you want to access the content of the data object, you need to dereference the data reference first.

Q44. Can a class be defined without a constructor ?

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

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

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

once .

Q46. What Is A Class In Ooabap?

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

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

Ans: 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.

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

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

Q49. Can We Declare Events In Interface In Ooabap ?

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

Q50. What Is A Singleton Class In Ooabap ?

Ans: Singleton class is a class which allows to instantiate(Create Object) only

Q51. What Is A Global Class In Sap ?

Ans: 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

Q52. What Is A Local Class In Sap ?

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

Q53. What Is An Event In Ooabap ?

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

Q54. How To Declare And Raise Events In Ooabap ?

Ans: 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

Q55. What Is A Constructor Method In Ooabap ?

Ans:

  • 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

Q56. What Is Abstract Method In Ooabap ?

Ans: Abstract methods is a method which doesn't contain any implementation.

Q57. What Is An Abstract Class In Ooabap ?

Ans:

  • 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.

Q58. Can We Instantiate Abstract Class In Ooabap ?

Ans:

  • 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.

Q59. What Is The Use Of 'defination Deferred' Keyword In Ooabap ?

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

Syntax : CLASSÂ Â DEFINITION DEFERED.

Q60. What Are The Advantages Of Oo Alv ?

Ans: 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.

Q61. What Are The Types Of Constructor's In Ooabap ? Explain ?

Ans: 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.

Q62. What Is A Polymorphism In Ooabap ?

Ans: 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.

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

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

Q64. What Is A Friend Class?

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

Q65. What Is Alias?

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

Q66. What Is Me Variable?

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

Q67. How To A Create Object For The Class?

Ans:

Data: ref type ref to .
Create object ref.

Q68. How To Call A Method?

Ans: Call method ref­>method_name .

Q69. What Are The Differences Local & Global Classes?

Ans:

  • 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).

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

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

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

Ans:

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

Q72. How To Define A Class Locally?

Ans:

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

Q73. How To Create An Object For Private Class?

Ans: 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.




Q1) What is OOPS ABAP?

Ans: Object orientation (OO), or to be more precise, object-oriented programming, is a problem-solving method in which the software solution reflects objects in the real world.

A comprehensive introduction to object orientation as a whole would go far beyond the limits of this introduction to ABAP Objects. This documentation introduces a selection of terms that are used universally in object orientation and also occur in ABAP Objects. In subsequent sections, it goes on to discuss in more detail how these terms are used in ABAP Objects. The end of this section contains a list of further reading, with a selection of titles about object orientation.

Q2) What is the difference between Class and Object?

Ans: A-Class is actually a blueprint or a template to create an Object. Whereas an object is an actual instance of a Class. 

Q3) How can polymorphism be implemented?

Ans: Implement polymorphism:

  • Method Overriding
  • Method Overloading
  • Operator Overloading

Q4) What is Inheritance?

Ans: In OOPs terminology, inheritance is a way to form new classes using classes that have already been defined. Inheritance is intended to help reuse existing code with little or no modification. The new classes, known as derived classes, inherit attributes and behaviour of the pre-existing classes, which are referred to as base classes.

Q5) What is Method Overriding?

Ans: Method overriding allows a subclass to override a specific implementation of a method that is already provided by one of its superclasses.

A subclass can give its own definition of methods but need to have the same signature as the method in its superclass. This means that when overriding a method the subclass method has to have the same name and parameter list as the super class's overridden method.

Q6) What is Method Overloading?

Ans: Method overloading is in a class have many methods having the same name but different parameter called overloading or static polymorphism.

Q7) What is Aggregation?

Ans: An aggregation is a special form of association. Aggregation is the composition of an object out of a set of parts. For example, a car is an aggregation of the engine, tires, brakes, etc.

Aggregation represents a "Has" relationship like a car has an engine.

Q8) What is an object-oriented programming language?

Ans: An object-oriented programming language allows concepts such as abstraction, modularity, encapsulation, polymorphism, and inheritance. Simula is the first object-oriented language. Objects are said to be the most important part of an object-oriented language. The concept revolves around making simulation programs around an object.

Want to represent real-time objects of a class, enroll in our SAP OOPS ABAP Training

Q9) What are the core ABAP oops concepts?

Ans:

InheritanceInheritance is the ability of an object to inherit the properties and methods of another object. This characteristic leads to the creation of families of objects (just like families exist for humans) with parent objects and child objects.

PolymorphismPolymorphism is about an object's ability to provide context when methods or operators are called on the object. In object-oriented programming, polymorphism (from the Greek meaning "having multiple forms") is the characteristic of being able to assign a different meaning to a particular symbol or "operator" in different contexts. A simple example is two classes that inherit from a common parent and implement the same virtual method.

Encapsulation: Encapsulation: Encapsulation is the ability that an object has to contain and restrict access to its members. Encapsulation is a key concept of object programming that ensures the autonomy and integrity of the objects. Abstraction: Another OOPS concept related to encapsulation that is less widely used but gaining ground is an abstraction.

Abstraction: Through the process of abstraction, a programmer hides all but the relevant data about an object in order to reduce complexity and increase efficiency. In the same way that abstraction sometimes works in art, the object that remains is a representation of the original, with unwanted detail omitted. The resulting object itself can be referred to as an abstraction, meaning a named entity made up of selected attributes and behaviour specific to a particular usage of the originating entity.

Q10) What is UML?

Ans: UML (Unified Modeling Language) is a standardized modelling language. It is used for the specification, construction, visualization, and documentation of models for software systems and enables uniform communication between various users.

  • UML does not describe the steps in the object-oriented development process.
  • SAP uses UML as the company-wide standard for object-oriented modelling.
  • UML describes a number of different diagram types in order to represent different views of a system.

Q11) What are the types of Objects and Classes?

Ans: There are two types of Objects: Instance Object and Static Object.

Two types of Classes:

  • Instance class.
  • Static Class. 

Q12) What are the types of classes which can be created?

Ans:  We can create four types of classes under the final and only modelled category(optional) with the private, protected, public, and abstract instantiation.

  • Usual Abap Class.
  • Exception Class(With/Without messages).
  • Persistent Class.
  • Test Class(ABAP Unit).

Q13) What are the types of classes which can be created?

Ans: We can create four types of classes under the final and only modelled category(optional) with the private, protected, public, and abstract instantiation.

  • Usual Abap Class.
  • Exception Class(With/Without messages).
  • Persistent Class.
  • Test Class(ABAP Unit).

Q14) What is a reference variable?

Ans: Objects can only be created and addressed using reference variables. Reference variables allow you to create and address objects. Reference variables can be defined in classes, allowing you to access objects from within a class.


Q15) What is an Object?

Ans: Object is an instance of a class. It has state, behaviour, and identity. It is also called an instance of a class.

Q16) What is meant by Binding?

Ans: Binding denotes the association of a name with a class.

Q17) What is meant by static binding?

Ans: Static binding is a binding in which the class association is made during compile time. This is also called as Early binding.

Q18) What is meant by Dynamic binding?

Ans: Dynamic binding is a binding in which the class association is not made until the object is created at execution time. It is also called as Late binding.

OO ABAP Interview Questions

Q19) Define Modularity?

Ans: Modularity is the property of a system that has been decomposed into a set of cohesive and loosely coupled modules.

Q20) What is meant by Persistence?

Ans: Persistence is the property of an object by which its existence transcends space and time.

Q21) What is collaboration?

Ans: Collaboration is a process whereby several objects cooperate to provide some higher-level behaviour.

Q22) What is a singleton?

Ans: If it is to be impossible to instantiate a class more than once (for example, because it serves as a data administrator or data container), you can use the singleton concept. The class is defined with the addition CREATE PRIVATE and FINAL and instantiated using its static constructor. A public static component could then make the reference to the class available to an external user.

Q23) What are the limitations of redefining a method?

Ans: Inherited methods can be redefined in subclasses Redefined methods must be re-implemented in subclasses. The signature of redefined methods cannot be changed Static methods cannot be redefined. In inheritance, static components are "shared": A class shares its non-private static attributes with all its subclasses. In ABAP Objects, you can not only add new components but also provide inherited methods with new implementations. This is known as redefinition. You can only redefine (public and protected) instance methods, other components (static methods, attributes and so on) cannot be redefined. Changes to method parameters (signature changes) are not possible.

Q24) What are static components? What is a component selector?

Ans: In inheritance, static components are "shared": A class shares its non-private static attributes with all its subclasses. => and -> are the component selectors used to refer.

Q25) What is the component instance?

Ans: A component instance is a running component that can be run in parallel with other instances of the same component.

Q26) How is Encapsulation implemented in OOPs?

Ans: Encapsulation means that the implementation of an object is hidden from other components in the system so that they cannot make assumptions about the internal status of the object and therefore dependencies on specific implementations do not arise.

Q27) What are BADIs? What are the BADI filters?

Ans: BADI - Business Add-Ins are enhancements to the standard version of the code of SAP.

Filter Badi- Business Add-Ins may be implemented on the basis of a filter value. If an enhancement for country-specific versions is provided for in the standard version, it is likely that different partners will want to implement this enhancement. The individual countries can create and activate their own implementation.

Q28) What is a functional Method?

Ans: Methods that have a RETURNING parameter are described as functional methods. These methods cannot have EXPORTING or CHANGING parameters but have many (or as few) IMPORTING parameters and exceptions as required.

Q29) What is a de-referenced variable? What is a garbage collector?

Ans: To go to an address before performing the operation a dereference variable is a pointer to the variable, not the variable itself. A pointer can be re-assigned any number of times while a reference cannot be reassigned after initialization. Field symbols are similar to dereference pointers. Thus, you can only access the content of the data object to which the field symbol points. (That is, field symbols use value semantics). If you want to access the content of the data object, you need to dereference the data reference first.

Q30) In Java, How to make an object completely encapsulated?

Ans: All the instance variables should be declared as private and public getter and setter methods should be provided for accessing the instance variables.

Q31) How is polymorphism achieved in java?

Ans: Inheritance, Overloading and Overriding are used to achieve Polymorphism in java.

Q32) What are the advantages of OOPs?

Ans: The major advantages of OOPs are:

FeatureDescription
SimplicitySoftware objects model real-world objects, so the complexity is reduced and the program structure is very clear.
ModularityEach object forms a separate entity whose internal workings are decoupled from other parts of the system.
ModifiabilityIt is easy to make minor changes in the data representation or the procedures in an OO program. Changes inside a class do not affect any other part of a program since the only public interface that the external world has to a class is through the use of methods.
ExtensibilityAdding new features or responding to changing operating environments can be solved by introducing a few new objects and modifying some existing ones.
 MaintainabilityObjects can be maintained separately, making locating and fixing problems easier.
Re-usabilityObjects can be reused in different programs

 

Q33) What are the main concepts of OOPs?

Ans: Following are the main concepts of OOPs:

  • Abstraction
  • Encapsulation
  • Inheritance
  • Polymorphism

Q34) What is Aggregation?

Ans: An aggregation is a special form of association. Aggregation is the composition of an object out of a set of parts. For example, a car is an aggregation of the engine, tires, brakes, etc.

Aggregation represents a "Has" relationship like a car has an engine.

Q35) What is the Association?

Ans: Association defines a relationship between different objects of different classes which allows one object instance to cause another to perform an action on its behalf.

ABAP OOPS Interview Questions

Q36) What is an object-oriented programming language?

Ans: Object-oriented programming language allows concepts such as abstraction, modularity, encapsulation, polymorphism, and inheritance. Simula is the first object-oriented language. Objects are said to be the most important part of an object-oriented language. The concept revolves around making simulation programs around an object.

Q37) What is message passing in object-oriented programming?

Ans: Message passing is a method by which an object sends data to another object or requests other objects to invoke the method. This is also known as interfacing. It acts as a messenger from one object to another object to convey specific instructions.

Want to represent real-time objects of a class, enroll in our SAP ABAP Training

Q38) What is Method Overloading?

Ans: Method overloading is the ability to define several methods all with the same name.

Q39) What is Operator Overloading?

Ans: The operator overloading is a specific case of polymorphisms in which some or all operators like +, -, %, etc. are treated as polymorphic functions and as such have different behaviors depending on the types of its operands.

Q40) What do you mean by Object Slicing?

Ans; When a derived class object is assigned to a base class, only the base class's part of the content in the derived object is copied to the base class, leaving behind the derived class-specific contents. This is referred to as Object Slicing.

Class Base

{

public int i;

};

class Derived: public Base

{

public int j;

};

int main()

{

Base objB;

Derived objD;

objB = objD;

//Here objD contains both i and j.

//But only i is copied to objB.

}

Q41) Give some examples of programming languages that support object-oriented characteristics?

Ans: Some of the programming languages which support object-oriented characteristics are ABAP, C++, Perl, LISP, Java, C#, Tcl, VB.Net, Ruby, Python, PHP, etc. The popularity of these languages has increased considerably as they can solve complex problems with ease.

Q42) What is a constructor?

Ans: A constructor is an operation that creates an object and/or initializes its state.

Q43) What is a destructor?

Ans: Destructor is an operation that frees the state of an object and/or destroys the object itself. In Java, there is no concept of destructors. It's taken care of by the JVM.

Q44) What is the base class?

Ans: Base class is the most generalized class in a class structure. Most applications have such root classes. In Java, Object is the base class for all classes.

Q45) What is a subclass?

Ans: Subclass is a class that inherits from one or more classes.

Q46) What is a superclass?

Ans: Superclass is a class from which another class inherits.

Q47) What is an ABAP data dictionary?

Ans: ABAP 4 data dictionary describes the logical structures of the objects used in application development and shows how they are mapped to the underlying relational database in tables/views.

Q48) What are the events in the ABAP/4 language?

Ans: Initialization, At selection-screen,Start-of-selection, end-of-selection, top-of-page, end-of-page, At line-selection,At user-command, At PF, Get, At New, At LAST, AT END, AT FIRST.

Q49) How to Create an Object for Private Class?

Ans: Creating an object for the private class is not possible, but can access the private class’s static method. We can call the method using its class name and import that object. For instance, take one static method having an exporting parameter inside the private class and write the object creation code in that static method and then export that object.

Q50) Mention the major differences between the Static Class and Singleton in Sap ABAP?

Ans: Understanding static components are essential before going to static classes in Sap ABAP Static Components: Static Components such as static attributes, static methods, and static events exists globally, it’s not necessary to create an instance/object of the class to access them, simply we can access them using static component selector =>. Singleton Class: The class that does not allow creating multiple instances to access any object. Static Class: The class that contains only static components without instance components is referred to as a static class.




1. What Is OOPS ABAP?
Answer: Object orientation (OO), or to be more precise, object-oriented programming, is a problem-solving method in which the software solution reflects objects in the real world.

A comprehensive introduction to object orientation as a whole would go far beyond the limits of this introduction to ABAP Objects. This documentation introduces a selection of terms that are used universally in object orientation and also occur in ABAP Objects. In subsequent sections, it goes on to discuss in more detail how these terms are used in ABAP Objects. The end of this section contains a list of further reading, with a selection of titles about object orientation.

2. What are the core ABAP oops concepts?
Answer: Inheritance: Inheritance is the ability of an object to inherit the properties and methods of another object. This characteristic leads to the creation of families of objects (just like families exist for humans) with parent objects and child objects.
Polymorphism: Polymorphism is about an objects ability to provide context when methods or operators are called on the object.

3. What is a reference variable?
Answer: Objects can only be created and addressed using reference variables. Reference variables allow you to create and address objects. Reference variables can be defined in classes, allowing you to access objects from within a class.

4. What are the limitations of redefining a method?
Answer:
Inherited methods can be redefined in subclasses Redefined methods must be re-implemented in subclasses. The signature of redefined methods cannot be changed Static methods cannot be redefined. In inheritance, static components are “shared”: A class shares its non-private static attributes with all its subclasses. In ABAP Objects, you can not only add new components but also provide inherited methods with new implementations. This is known as redefinition. You can only redefine (public and protected) instance methods, other components (static methods, attributes and so on) cannot be redefined. Changes to method parameters (signature changes) are not possible.

5. What Is A Singleton Class In Ooabap?
Answer: Singleton class is a class which allows instantiating (Create Object) only.

6. What Are The Advantages Of Oo Alv?
Answer: Some of the main advantages of Object Oriented ALV

  • We have no events available in the classes when compared to ALV with function modules which give 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 a custom container with which we can control the size of the 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 to ALV grid data.

7. What Are The Differences Local & Global Classes?Answer: Local classes are defined locally within 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 the ABAP environment. Global classes are centrally defined in a repository. Transaction code for global classes is SE24(class builder). 

8. Can We Instantiate Abstract Class In Ooabap?
Answer: we cannot create an object to the abstract class instead create an object to the child class and call the methods.
An abstract class is mainly used for creating inheritance.

9. What Is A Class In Ooabap?
Answer: Class is a user-defined data type which contains methods, events, attributes, interfaces, etc.

10. What Is The Difference Between Abstract Class And Interface?
Answer: 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 an instance for the abstract class is mainly for inheritance.
The interface contains methods without implementation.

11. Is It Mandatory To Implement All Methods Of Interface In The Class Which Includes Interface?
Answer: No it is not mandatory to implement all normal interface methods but it is mandatory to implement all Abstract methods.

12. What Is An Abstract Class In Ooabap?
Answer: It is a class which contains methods with implementation as well as methods without implementation.
An abstract class is a class which contains at least one abstract method.

13. What Is A Polymorphism In Ooabap?
Answer: Polymorphism is a concept by which the same method names will behave differently in different classes i.e each method will have its own implementation in different classes but with the same name.

14. What Is The Difference Between Function Group And Classes?
Answer: We can create many instances of the same class within a program, but we cannot create many instances of function group.

15. WHAT IS AN INTERFACE IN OOABAP?
Answer: The interface is class which contains methods without implementations.

16. What Are The Types Of Constructors In Ooabap? Explain?
Answer: CONSTRUCTOR’s are a special type of methods, the constructor method is executed automatically whenever an object is created or instantiated.

  • Constructor: This method is executed automatically whenever an 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 an object is created, this is used to set default values globally irrespective of instances/objects. The name of the static constructor is CLASS_ CONSTRUCTOR.

17. What is Encapsulation in Object-Oriented Programming(OOP)?
Answer: Encapsulation is the main concept in OOP. Encapsulation means hiding attributes and methods from the outside world, so in this way, we can restrict the visibility of an object( an instance of a class) components(attributes and methods).

18. What is Inheritance in OO ABAP?
Answer: Deriving a new class from an existing class is called Inheritance. The existing class is called as Superclass and derived new class is called as Subclass. Derived class get all attributes and methods from the superclass and in addition to that, we create new attributes and methods.

19. What is Narrow Casting?
Answer: Definition: The assignment of a subclass instance to a reference variable of the type “reference to superclass” is described as a narrowing cast, because you are switching from a more detailed view to a one with less detail. It is also called as up-casting.

Use of narrowing casting:

A user who is not interested in the finer points of cars, trucks, and busses (but only, for example, in the fuel consumption and tank gauge) does not need to know about them. This user only wants and needs to work with (references to) the lcl_vehicle(superclass) class. However, in order to allow the user to work with cars, buses, or trucks, you generally need a narrowing cast.

Principle of narrowing casting:

1. In narrowing casting the object which is created with reference to the subclass is assigned to the reference of type superclass.
2. Using the superclass reference it is possible to access the methods from the object which are only defined at the superclass.
3. This access is also called as generic access as superclass is normally called a general class.

20. What are an abstraction, encapsulation, and polymorphism?
Answer: Abstraction: Everything is visualized in terms of classes and objects.

Encapsulation The wrapping up of data and methods into a single unit (called class) is known as Encapsulation. The data is not accessible to the outside world only those methods, which are wrapped in the class, can access it.

Polymorphism: Methods of the same name behave differently in different classes. Identical(identically-named) methods behave differently in different classes. Object-oriented programming contains constructions called interfaces. They enable you to address methods with the same name in different objects. Although the form of address is always the same, the implementation of the method is specific to a particular class.

21. What Is Alias Name In Ooabap? Answer: Alias is an alias name for the interface method implemented in the class.  

22. How do you achieve encapsulation in OO ABAP?
Answer: We can achieve encapsulation in OO ABAP by using PUBLIC, PRIVATE and PROTECTED keywords in OO ABAP. These are also called as access specifiers.

23. What is the Event Handler Technique in Object-oriented ABAP?
Answer: Event is a mechanism by which method of one class can raise method of another class, without the hazard of instantiating that class. It provides to raise the method (event handler method) of one class with the help of another method in the same or different class (triggering method).

The below steps is required to have the event handler in the class:-

  • Create an event in a class.
  • Create a triggering method in the same class which will raise the event.
  • Create an event handler method for the event in the same/other class.
  • Register the event handler method in the program.

Now, the above settings are complete for an event handler in class. Create an object from the class containing the event and call the triggering method to raise the event.

24. What is Method Overriding?
Answer: Method overriding allows a subclass to override a specific implementation of a method that is already provided by one of its superclasses.

A subclass can give its own definition of methods but need to have the same signature as the method in its superclass. This means that when overriding a method the subclass’s method has to have the same name and parameter list like the super class’s overridden method.

25. What is UML?
Answer: UML (Unified Modeling Language) is a standardized modeling language. It is used for the specification, construction, visualization, and documentation of models for software systems and enables uniform communication between various users.

  • UML does not describe the steps in the object-oriented development process.
  • SAP uses UML as the company-wide standard for object-oriented modeling.
  • UML describes a number of different diagram types in order to represent different views of a system.

26. How polymorphism can be implemented?
Answer: Some examples to implement polymorphism:

  • Method Overriding
  • Method Overloading
  • Operator Overloading

27. What Is The Difference In Attributes Defined In The Public Versus Private Section Of A Class? Answer: Public attributes can be accessed by class, subclasses and other classes whereas Private attributes can be accessed by the class itself only. 

28. What are Abstract Classes and Methods in Object-Oriented Programming?
Answer: Abstract Class: Classes which contain one or more abstract methods or abstract properties, such methods or properties do not provide the implementation. These abstract methods or properties are implemented in the derived classes (Sub-classes).
Abstract classes do not create any instances to that class objects

Use of Abstract class: We can define some common functionality in Abstract class (Super-class) and those can be used in derived classes (Subclasses).

29. What is the Visibility of Component?
Answer: Each class component has visibility. In ABAP Objects the whole class definition is separated into three visibility sections: PUBLIC, PROTECTED, and PRIVATE.

1) Data declared in public section can be accessed by the class itself, by its sub-classes as well as by other users outside the class.
2) Data declared in the protected section can be accessed by the class itself, and also by its sub-classes but not by external users outside the class.
3) Data declared in the private section can be accessed by the class only, but not by its sub-classes and by external users outside the class.

30. What is the difference between Class and Object?
Answer: A-Class is actually a blueprint or a template to create an Object. Whereas an object is an actual instance of a Class. For example Employee in a class, while John is a real employee which is an Object of Employee Class. 

31. What is Inheritance?
Answer: In OOPs terminology, inheritance is a way to form new classes using classes that have already been defined. Inheritance is intended to help reuse existing code with little or no modification. The new classes, known as derived classes, inherit attributes and behavior of the pre-existing classes, which are referred to as base classes.

32. What is object-oriented programming language?
Answer: Object-oriented programming language allows concepts such as abstraction, modularity, encapsulation, polymorphism, and inheritance. Simula is the first object-oriented language. Objects are said to be the most important part of an object-oriented language. The concept revolves around making simulation programs around an object.

33. What are the types of Objects and Classes?
Answer: In general, there are two types of Objects: Instance Object and Static Object and as such there are two types of Classes: Instance class and Static Class. Specifically, when it comes to visibility, Private class, Protected class, and Public classes are the types of classes one can have.

34. What is the difference between Abstract method and a Final method?
Answer: Abstract method

Abstract instance methods are used to specify particular interfaces for subclasses, without having to immediately provide an implementation for them. Abstract methods need to be redefined and thereby implemented in the subclass (here you also need to include the corresponding redefinition statement in the DEFINITION part of the subclass). Classes with at least one abstract method are themselves abstract. Static methods and constructors cannot be abstract (they cannot be redefined).
Abstract (instance) methods are defined in the class, but not implemented
They must be redefined in subclasses.

35. How is Encapsulation implemented in OOPs?
Answer: Encapsulation means that the implementation of an object is hidden from other components in the system so that they cannot make assumptions about the internal status of the object and therefore dependencies on specific implementations do not arise.

36. What Is An Event In Ooabap?
Answer: Event is a mechanism by which method of one class can raise method of another class, without the hazard of instantiating that class.

37. What Is A Constructor Method In Ooabap?
Answer:

  • These are a special type of methods constructor method is executed automatically whenever an 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.

38. Can We Defined A Class Without A Constructor In Ooabap
Answer: Yes, the class can be created without any constructor. The default constructor will be created when we define a class without a constructor.

39. How To Create An Object For Private Class?
Answer: In general, we can not create an object for a private class, but we can access the 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 the private class and write the object creation code in that static method and export that object.

40. What Is The Difference Between Singleton And Static Class In Sap Abap?
Answer: 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.

41. What is a de-referenced variable? What is a garbage collector?
Answer: To go to an address before performing the operation a dereference variable is a pointer to the variable, not the variable itself. A pointer can be re-assigned any number of times while a reference cannot be reassigned after initialization. Field symbols are similar to dereference pointers. Thus, you can only access the content of the data object to which the field symbol points. (That is, field symbols use value semantics). If you want to access the content of the data object, you need to dereference the data reference first.

42. How Many Types Of Classes Are There In Ooabap?
Answer:

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

43. What are the different components available in Class\?
Answer:
Attributes, Methods, Events, Types, and Constants are different components which are available in Class

44. What are the principles of Object-Oriented Programming(OOP)?
Answer: There are 4 major principles in OO Programming. They are of Abstraction, Encapsulation, Inheritance, and Polymorphism.

45. What are the Instance and Static Components?
Answer: Instance components: These components exist separately in each instance (object) of the class and are referred using instance component selector using ->
Static components: These components exist globally for a class and are referred to using a static component selector.

46. What is a Narrowing Cast? How can you implement it?
Answer: The assignment of a subclass instance to a reference variable of the type “reference to superclass” is described as a narrowing cast, because you are switching from a more detailed view to a one with less detail.

47. What is Method Overloading?
Answer: Method overloading is in a class have many methods having the same name but different parameter called overloading or static polymorphism.

48. What is FRIENDS keyword?
Answer: In any Object Oriented programming language, access to private or protected components – both methods and attributes – would be prohibited. If someone tries to access them, the compiler would generate a syntax error.
Sometimes, it would be advantageous to give access to these protected and private attributes to other classes. This can be achieved using FRIENDS addition.

49. How To Declare And Raise Events In Ooabap?
Answer: We need to follow the 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 the event – handler method
  • Create a triggering method which will raise the event Use set
  • handler and register the event handler method to a particular instance in the program

50. What is the Use of final class?
Answer: Final Classes and Methods in Object-Oriented Programming

Final Class: A class that is defined as a final class can not be inherited further. All Methods of a final class are inherently final and must not be declared as final in the class definition. Also, a final method can not be redefined further.
If only a method of a class is final then that class can be inherited but that method cannot be redefined.

If you don’t want anyone else to change or override the functionality of your class then you can define it as final. Thus no one can inherit and modify the features of this class.





SAP OOPS ABAP Interview Questions And Answers



1. What is the concept of Object-Oriented ABAP?

Answer: Object Oriented ABAP came up with the concept of representing Real-Time objects in classes. Ex: Instances at run time.

2. What is OOPS ABAP ?

Answer: Object orientation (OO), or to be more precise, object-oriented programming, is a problem-solving method in which the software solution reflects objects in the real world.

A comprehensive introduction to object orientation as a whole would go far beyond the limits of this introduction to ABAP Objects. This documentation introduces a selection of terms that are used universally in object orientation and also occur in ABAP Objects. In subsequent sections, it goes on to discuss in more detail how these terms are used in ABAP Objects. The end of this section contains a list of further reading, with a selection of titles about object orientation.

Ad by Valueimpression

3. What is an Interface in OOABAP?

Answer: Interface is class which contains methods without implementations.

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

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

5. What Is An Interface In Ooabap?

Answer: Interface is class which contains methods without implementations.

6. Can We Instantiate The Interface?

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

7. Can We Achieve Multiple Inheritance Using Interfaces?

Answer: Yes, by using interface concept in SAP ABAp, we can achieve multiple inheritances

8. What is the Difference between Class and Object?

Answer: A Class is actually a blueprint or a template to create an Object. Whereas an Object is an actual instance of a Class. 

9. How can polymorphism be implemented?

Answer:

  1. Implement polymorphism:
  2. Method Overriding
  3. Method Overloading
  4. Operator Overloading

10. What is a reference variable?


Answer: Objects can only be created and addressed using reference variables. Reference variables allow you to create and address objects. Reference variables can be defined in classes, allowing you to access objects from within a class.




11. What are the limitations of redefining a method?

Answer:

Inherited methods can be redefined in subclasses Redefined methods must be re-implemented in subclasses. The signature of redefined methods cannot be changed Static methods cannot be redefined. In inheritance, static components are “shared”: A class shares its non-private static attributes with all its subclasses. In ABAP Objects, you can not only add new components but also provide inherited methods with new implementations. This is known as redefinition. You can only redefine (public and protected) instance methods, other components (static methods, attributes and so on) cannot be redefined. Changes to method parameters (signature changes) are not possible.

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

Answer: 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.


13. What is Method Overriding?

Answer: Method overriding allows a subclass to override a specific implementation of a method that is already provided by one of its superclasses.

A subclass can give its own definition of methods but need to have the same signature as the method in its superclass. This means that when overriding a method the subclass method has to have the same name and parameter list like the super class’s overridden method.

14. Can we instantiate the interface?

Answer: No, we can not instantiate interface using create object keyword

15.  What is Method Overloading ?

Answer: Method overloading is in a class have many methods having same name but different parameter called overloading or static polymorphism

16. What is Aggregation ?

Answer: Aggregation is a special form of association. Aggregation is the composition of an object out of a set of parts. For example, a car is an aggregation of engine, tyres, brakes, etc.

Aggregation represents a “Has” relationship like a car has a engine.

17. What is object-oriented programming language ?

Answer: Object oriented programming language allows concepts such as abstraction, modularity, encapsulation, polymorphism and inheritance. Simula is the first object oriented language. Objects are said to be the most important part of object oriented language. Concept revolves around making simulation programs around an object.

18. What Are The Advantages Of Oo Alv?


Answer: Some of the main advantages of Object Oriented ALV

We have no events available in the classes when compared to ALV with function modules which give 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 a custom container with which we can control the size of the 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 to ALV grid data.

19. What are the core ABAP oops concepts ?

Inheritance:

Inheritance is the ability of an object to inherit the properties and methods of another object. This characteristic leads to the creation of families of objects (just like families exist for humans) with parent objects and child objects.

Polymorphism:

Polymorphism is about an objects ability to provide context when methods or operators are called on the object. In object-oriented programming, polymorphism (from the Greek meaning “having multiple forms”) is the characteristic of being able to assign a different meaning to a particular symbol or “operator” in different contexts. The simple example is two classes that inherit from a common parent and implement the same virtual method.

Encapsulation:

Encapsulation: Encapsulation is the ability that an object has to contain and restrict the access to its members. Encapsulation is a key concept of object programming that ensures the autonomy and integrity of the objects. Abstraction: Another OOPS concept related to encapsulation that is less widely used but gaining ground is abstraction.

Abstraction:

Through the process of abstraction, a programmer hides all but the relevant data about an object in order to reduce complexity and increase efficiency. In the same way that abstraction sometimes works in art, the object that remains is a representation of the original, with unwanted detail omitted. The resulting object itself can be referred to as an abstraction, meaning a named entity made up of selected attributes and behavior specific to a particular usage of the originating entity.

20. What is an Interface in OOABAP?

Answer: Interface is class which contains methods without implementations.

Top SAP OOPS ABAP Interview Questions And Answers

21. What is UML?

Answer: UML (Unified Modeling Language) is a standardized modeling language. It is used for the specification, construction, visualization, and documentation of models for software systems and enables uniform communication between various users.

UML does not describe the steps in the object-oriented development process.

SAP uses UML as the company-wide standard for object-oriented modeling.

UML describes a number of different diagram types in order to represent different views of a system.

22. What is a reference variable?

Answer: Objects can only be created and addressed using reference variables. Reference variables allow you to create and address objects. Reference variables can be defined in classes, allowing you to access objects from within a class.

23. What is the difference between Abstract method and a Final method ?

Answer: Abstract method

Abstract instance methods are used to specify particular interfaces for subclasses, without having to immediately provide implementation for them. Abstract methods need to be redefined and thereby implemented in the subclass (here you also need to include the corresponding redefinition statement in the DEFINITION part of the subclass). Classes with at least one abstract method are themselves abstract. Static methods and constructors cannot be abstract (they cannot be redefined).

Abstract (instance) methods are defined in the class, but not implemented

They must be redefined in subclasses.

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

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

25. What Is An Interface In Ooabap?

Answer: The interface is class which contains methods without implementations.

26. Can We Achieve Multiple Inheritance Using Interfaces?

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

27. Does Polymorphism Achieved Through Interfaces?

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

Frequently Asked SAP OOPS ABAP Interview Questions And Answers

28. What is a Widening Cast ?

Answer: The widening cast is, as with inheritance, the opposite of the narrowing cast: Here it is used to retrieve a class reference from an interface reference.

29. What is a singleton ?

Answer: If it is to be impossible to instantiate a class more than once (for example, because it serves as a data administrator or data container), you can use the singleton concept. The class is defined with the addition CREATE PRIVATE and FINAL and instantiated using its static constructor. A public static component could then make the reference to the class available to an external user.

30. What Are The Differences Local & Global Classes?

Answer: Local classes are defined locally within 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 the ABAP environment. Global classes are centrally defined in a repository. Transaction code for global classes is SE24(class builder). 

31. What are static components? What is a component selector ?

Answer: In inheritance, static components are “shared”: A class shares its non-private static attributes with all its subclasses. => and -> are the component selectors used to refer.

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

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

33. Can We Raise Events In Interface?

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




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

    Answer :

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

  2. Question 2. What Is An Interface In Ooabap?

    Answer :

    Interface is class which contains methods without implementations.

  3. Question 3. Can We Instantiate The Interface?

    Answer :

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

  4. Question 4. Can We Achieve Multiple Inheritance Using Interfaces?

    Answer :

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

  5. Question 5. Does Polymorphism Achieved Through Interfaces?

    Answer :

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

  6. Question 6. What Is The Difference Between Abstract Class And Interface?

    Answer :

    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 .

  7. Question 7. What Is Alias Name In Ooabap?

    Answer :

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

  8.  
  9. Question 8. Can We Raise Events In Interface?

    Answer :

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


  10. Question 9. What Is A Single-ton Class?

    Answer :

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

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

    Answer :

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

  12. Question 11. What Is The Difference In An Instance Method And A Static Method?

    Answer :

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

  13. Question 12. What Is A Class In Ooabap?

    Answer :

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


  14. Question 13. What Is The Difference Between Singleton And Static Class In Sap Abap ?

    Answer :

    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.

  15. Question 14. Can We Make Methods Of Interface As Abstract And Final In Ooabap ?

    Answer :

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


  16. Question 15. Can We Declare Events In Interface In Ooabap ?

    Answer :

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

  17. Question 16. What Is A Singleton Class In Ooabap ?

    Answer :

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


  18. Question 17. What Is A Global Class In Sap ?

    Answer :

    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

  19. Question 18. What Is A Local Class In Sap ?

    Answer :

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


  20. Question 19. What Is An Event In Ooabap ?

    Answer :

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

  21. Question 20. How To Declare And Raise Events In Ooabap ?

    Answer :

    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


  22. Question 21. What Is A Constructor Method In Ooabap ?

    Answer :

    • 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

  23. Question 22. What Is Abstract Method In Ooabap ?

    Answer :

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


  24. Question 23. What Is An Abstract Class In Ooabap ?

    Answer :

    • 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.

  25. Question 24. Can We Instantiate Abstract Class In Ooabap ?

    Answer :

    • 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.


  26. Question 25. What Is The Use Of 'defination Deferred' Keyword In Ooabap ?

    Answer :

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

    Syntax : CLASSÂ Â DEFINITION DEFERED.

  27. Question 26. What Are The Advantages Of Oo Alv ?

    Answer :

    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.


  28. Question 27. What Are The Types Of Constructor's In Ooabap ? Explain ?

    Answer :

    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.

  29. Question 28. What Is A Polymorphism In Ooabap ?

    Answer :

    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.

  30. Question 29. Can We Defined A Class Without A Constructor In Ooabap ?

    Answer :

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

  31. Question 30. What Is A Friend Class?

    Answer :

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

  32. Question 31. What Is Alias?

    Answer :

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

  33. Question 32. What Is Me Variable?

    Answer :

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

  34. Question 33. How To Create A Global Class?

    Answer :

    With tcode SE24.

  35. Question 34. How To A Create Object For The Class?

    Answer :

    Data: ref type ref to .
    Create object ref.

  36. Question 35. How To Call A Method?

    Answer :

    Call method ref­>method_name .

  37. Question 36. What Are The Differences Local & Global Classes?

    Answer :

    • 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).

  38. Question 37. What Is The Difference Between Function Group And Classes?

    Answer :

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

  39. Question 38. How Many Types Of Classes Are There In Ooabap?

    Answer :

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

  40. Question 39. How To Define A Class Locally?

    Answer :

    class <cl_name> definition.
    Public section.
    Methods: m1 importing p1 type <c>
    Exporting p2 type <i>
    Changing p3 type <n>
    Returning p4 type <i>
    Exceptions <e1>.
    Protected section.
    Private section.
    Endclass.
    Class <c1_name> implementation.
    Method m1.­­­­­­
    Endmethod.
    Endclass

  41. Question 40. How To Create An Object For Private Class?

    Answer :

    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.



SAP NUTS:


What are the main features of Object-oriented programming?


  • Encapsulation
  • Plomorphysm
  • Inheritance
  • Abstraction


What is the class definition?

A class is an abstract definition of a real-world object.

What is an Object?


An object is a real-world Object that contains properties and data.


How many types of classes in oops?


Public class
Private Class
Final Class
Singleton Class
Abstract class
Friend class
Persistent class

What is the difference between class and function group?


We can't create many instances of the function group but we create a number of instances for a class within an ABAP program.

What are the components of the classes?


Methods and attributes are components of the classes

What are the differences between local and global classes?


Locals is defined within the ABAP program but Global class is defined in the class builder SE24, available for all SAP applications.

What are the constructors and the difference between them?


A constructor is a special kind of method .it will be called automatically when the object is instantiated in the class. A class contains the two types of constructors default which are static and instance 

static constructor called only one time when class loaded. Instance constructors are instance-specific that is object-specific, whenever we created a new object, instance constructors will be calling.

How do you create objects for the class?


Data:ob1 type ref to <class name>.

Create Object Ob1.

Can we instantiate the class within the implementation of other classes?


It is possible.

What are the static attribute and a static method?

static attributes and methods are class-specific and memory will be allocated only once for these ones irrespective of the number of objects created.

we can access these using 
Call method <class name>=>Method_name.


Where do you create a global class?


class Builder SE24.

What is the ME reference variable?


In the class, without creating an object, we call the method using self-reference object ME.


What is a Final Class?

  The final class does not have any child classes and the final methods can not be redefined.


What is a friend class?


It can access the private components of its friend classes.


What is a persistent class?


The classes of these objects must be created as persistent classes in the Class Builder.  (As a template for objects, every class is persistent). Rather, it means that the objects of that class and their state are managed by the Persistence Service. When the Class Builder creates a persistent class, it automatically generates an associated class, known as the class actor or class agent, whose methods manage the objects of persistent classes. As well as their identity, persistent classes can contain key attributes, which allow the Persistence Service to ensure that the content of each persistent object is unique.

What is a singleton class?


Only one object create for the singleton class and it can be instantiated only once.


Singleton pattern : is the one of the simplest design patterns which involves only one class which instantiates itself to make sure that it creates one instance.Singleton ensues that it has only one instance and provides global point of access to the object.

So when you create a singleton class it does not allow you to create multiple instances of the class,rather a single instance will be created which acts a global access point to reference that class through out the lifetime of the application component

The best examples are the logger classes.
Let me explain with a simplest nearby example, suppose you log into your Facebook account so one instance will be created for you until you logout and with the same instance you can visit pages/profiles/message or cross application validations will be done.

Static Class: is a class which needs no instance to access its components.
You can directly access the components using the “=>” operator.

Further more singleton classes are always a private class which cant be instantiated by simply creating a reference to the class and then creating an object!!!
No it won’t work.
You need to have an private attribute declared in that singleton class which has a type reference to the same class.



Comments

Popular posts from this blog

CDS tutorial and interview questions

AMDP SAP HANA

Differences