Ooabap Interview Questions
Ooabap Interview Questions
if u declare one method as a static then we can call that method using class name, that method is independent of that object.You declare
them using the CLASS-DATA statement.
if u declare one method as a instance then we can call that method using object name, that method is dependent of that object.You declare
them using the DATA statement.
2.
if u declare one attribute as a static then we can use that attribute through class name, that attribute is independent of that object.You declare
static methods using the CLASS-METHODS statement.
if u declare one attribute as a instance then we can use that attribute through object name, that attribute is dependent of that object.You
declare instance methods using the METHODS statement.
Instance Constructors
Every class has an instance constructor called constructor. This is an exception to the rule that states that component names
within an inheritance tree must be unique. However, the instance constructors of the various classes in an inheritance tree are
fully independent of one another. You cannot redefine the instance constructor of a superclass in a subclass, neither can you call
one specifically using the statement CALL METHOD CONSTRUCTOR. Consequently, no naming conflicts can occur.
The instance constructor of a class is called by the system when you instantiate the class using CREATE OBJECT. Since a
subclass contains all of the visible attributes of its superclasses, which can also be set by instance constructors, the instance
constructor of a subclass has to ensure that the instance constructors of all of its superclasses are also called. To do this, the
instance constructor of each subclass must contain a CALL METHOD SUPER->CONSTRUCTOR statement. The only
exception to this rule are direct subclasses of the root node OBJECT.
Static Constructors
Every class has a static constructor called class_constructor. As far as the namespace within an inheritance tree, the same
applies to static constructors as to instance constructors.
The first time you address a subclass in a program, its static constructor is executed. However, before it can be executed, the
static constructors of all of its superclasses must already have been executed. A static constructor may only be called once per
program. Therefore, when you first address a subclass, the system looks for the next-highest superclass whose static constructor
has not yet been executed. It executes the static constructor of that class, followed by those of all classes between that class and
the subclass you addressed.
3.
Classes in ABAP Objects can be declared either globally or locally. You define global classes and interfaces in the Class Builder
(Transaction SE24) in the ABAP Workbench. They are stored centrally in class pools in the class library in the R/3 Repository.
All of the ABAP programs in an R/3 System can access the global classes. Local classes are defined within an ABAP program.
Local classes and interfaces can only be used in the program in which they are defined. When you use a class in an ABAP
program, the system first searches for a local class with the specified name. If it does not find one, it then looks for a global
class. Apart from the visibility question, there is no difference between using a global class and using a local class.
Local classThere is, however, a significant difference in the way that local and global classes are designed. If you are defining a local class
that is only used in a single program, it is usually sufficient to define the outwardly visible components so that it fits into that
program. Global classes, on the other hand, must be able to be used anywhere. This means that certain restrictions apply when
you define the interface of a global class, since the system must be able to guarantee that any program using an object of a
global class can recognize the data type of each interface parameter.
4.
5.
6.
2.
ABAP Objects supports most normal ABAP statements (it's almost downward compatible) and also ads all object orientation
language elements, providing for example class definitions, object instantiation, inheritance.
3.
What ABAP objects doesn't support is obsolete ABAP elements like using internal table header lines.
What is the Transaction code for Global class and Global Interfaces ?
Se24
7.
Explicit means done by the programmer. Implicit means done by the tool
8.
9.
10.
11.
creating a class as a final means you can stop polymorphism. A class that is defined as 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.
12.
13.
Friend classes: - By default outside the class a object can access only public
components of the
class directly.
By using friend classes to enable the object to access any components of the
class directly
irresponsibility of the visibility for this consider the following session.
Consider two independent classes A and B.
If class A considers class B as friend by inside class B methods we can
instantiate class A
and use the instance we can access all the component of class A directly
irrespective of
the visibility.
14.
15.
16.
What is Inheritance ?
Inheritance: It is the process o acquiring the properties of other entity (class). The
advantage of
inheritance is reusability. They are three types of inheritance.
1) Single
2) Multiple
3) Multilevel
The class which gives the properties is called as super class are base class
and the class
which takes the properties is called as subclass (or) derived class.
Only public and protected components can be inherited.
In local classes we need to use the keyword inheriting from for achieving
inheritance.
1) Single inheritance: -
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
Can we restrict a method to have only single return type parameter ? How ?
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
What is Polymorphism ?
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
Can we define Interface Methods in Private section or Protected section? If No, Why?
69.
70.
How to call method if method contains Importing parameters and Exporting parameters" ?
71.
How to call method if method contains Importing parameters and Returning parameters" ?
72.
73.
74.
75.
What are CLASS Attributes or CLASS Variables? Static attributes are also called as Class variables?
76.
What are CLASS Methods ? Static Methods are also called as CLASS Methods ?
77.
78.
79.
80.
81.
Can we access Static methods of class without creating Object or not ? If Yes , How ?
82.
83.
84.
What is the Use Of "ME" keyword ? It's a Self Reference.What is the use of ?= ( Type cast operator ) in
OOABAP ?
85.
86.
87.
What is the difference between "Public section" , "Protected Section" & "Private Section"?
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
Details about interface, abstract class, final class, friend class , deferred class, load class.
98.
99.
100.
101.
102.
103.
104.
Concept of overriding.
105.
106.
107.
108.
109.
A brief Concept of narrow and widening casting related to OO ABAP with suitable real time examples.
110.
The handling mechnisim for class(friend,final,abstract), interface, events, constructor, methods
,inheritance ,data objects related to SE24 TCODE.
111.
112.
113.
114.
Brief idea about transient data object and persistence data object.
115.
116.
A brief description about Pseudo-code comment( Risk level and Duration)and handling
mechanisim.
117.
118.
119.
120.
A
brief
description
about
standard
classescl_gui_container,cl_gui_custom_container,cl_gui_docking_container,cl_gui_splitter_container,
cl_gui_easysplitter_container.
1. Explain about Object oriented programming?
Object oriented programming is one of the most popular methodologies in
software development. It offers a powerful model for creating computer programs.
It speeds the program development process, improves maintenance and enhances
re-usability of programs.
2. Object oriented Concepts?
Encapsulation:
It means combining data and code that acts up on data into one single unit of
organization, so that both are safe from out side interference. In OOAbap
encapsulation is achieved through classes.
Polymorphism:
It means many forms that mean the same method behaves differently in different
method calls.
Inheritance:
It means deriving a child class from base class; child class acquires all the
properties from base class.
Abstraction:
Abstraction simplifies a complex problem to a simpler problem by specifying and
modeling the class to the relevant problem scenario.
It simplifies the problem by giving the class its specific class of inheritance.
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 ia a class, while John is a real employee which is an Object of Employee Class.
34.How polymorphism can be implemented ?
Some examples to implement polymorphism:
Method Overriding
Method Overloading
Operator Overloading
35.What is Inheritance ?
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.
36.What is Method Overriding ?
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.
37.What is Method Overloading ?
Method overloading is in a class have many methods having same name but different parameter called overloading
or static polymorphism
38.What is Aggregation ?
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.
39.What is object oriented programming language ?
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.
40. 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.
41. Definition: Polymorphism
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.
42. Definition: 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.
43. Definition: 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.
55.
56.
57.
58.
59.
60.
61.
methods, attributes and so on) cannot be redefined. Changes to method parameters (signature changes) are not
possible.
What are static components? What is a component selector ?
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.
What are component instance ?
A component instance is a running component that can be run in parallel with other instances of the same
component.
How is Encapsulation implemented in OOPs ?
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.
What are BADIs? What are BADI filters ?
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 countryspecific 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.
What are the types of Exception classes ?
a. Global
b.
Local Exceptions Class.
Where can a protected method be accessed ?
Protected components Only visible within the class and its sub classes.
What is a signature of a method ?
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.
75) 18) What is the difference in attributes defined in the public versus private section
76) of a class?
77) 19) What is the keyword used to define static attributes?
78) 20) What is the difference in an instance method and a static method?
79) 21) What statement is used to instantiate an object?
80) 22) what is the purpose of garbage collector?
81) 23) When is the constructor method is executed?
82) 24) Is multiple inheritance is possible in ABAP objects?
83) 25) Static methods can be redefined ?
84) 26) A constructor method can be redefined ?
85) 27) What is a redefined method?
86) 28) What is a SUPER reference?
87) 29) What is class?
88) 30) What is object?
89) 31) Can we instantiate a class within implementation of other class?
90) 32) What is deferred key word ?
91) 33) Can static method use instance attribute ?
92) 34) Can a method call itself?
93) 35) What is preferred parameter ?
94) 36) can we pass returing parameter by reference ?
95) 37) What is ME variable?
96) 38) What are type of constructor and explain them?
97) 39) Can we have export parameter in Instance constructor?
98) 40) Can instance constructor raise exception ?
99) 41) Can we have static methods in interface?
100) 42) What is interface ?
101) 43) Is it mandatory to implement all the methods of interface ?
102) 44) What is alias ?
103) 45) What is Friendship?
104) 46) Can we have more than one event handler method for same event ?
105) 47) Can event have import parameter ?
106) 48) Can we call static constructor more than once in a program?
107) 49) How can we pass importing parameter ?
108) 50) Can we implement interface in private section of any class ?
109) 5 which of the following are correct ?
a.
2) Static attributes are visible in all classes in the inheritance tree?
110) Can we put non declarative statement e.g. START-OF-SELECTION within a class?
111)
Dear ABAPers if you know any answers please provide in the below