SAP-ABAP General Object Oriented Interview Questions Answers, here in this post we are going to provide some frequently asked general object oriented interview questions in SAP OOABAP. Refer this post for more details and interview questions on OOABAP. Click on Read More to read this post.
SAP-ABAP-General-Object-Oriented-Interview-Questions-Answers
SAP-ABAP General Object Oriented Interview Questions Answers, here in this post we are going to provide some frequently asked general object oriented interview questions in SAP OOABAP. Refer this post for more details and interview questions on OOABAP.
1)
Can abstract class can only be accessed using its static
components or its
subclasses?
Yes.
2)
What is a single-ton class?
A class that can be instantiated only once.
3) What are the differences between Abstract
Class and Interface?
- Abstract class can not be instantiated; it
can be accessed only by
static component or its subclass.
Interface,
which is an independent structure, is used to
implement in a class to extend the scope of a class, it allows
users to address different classes
via a universal point of
contact.
4) Answer the following
a)
An
abstract class can be instantiated.
- No.
b)
Any
class containing an abstract method has to be an abstract class
- Yes.
c)
To
implement an abstract method in a subclass, one needs to redefine this subclass
using the REDEFINITION addition.
- Yes.
5)
Answer the following
a)
Final
classes can have subclasses.
-
No.
b)
A
final method cannot be redefined in subclasses
- Yes.
c)
All
Methods of a final class are inherently final and must not be declared as final
in the class definition.
-
Yes.
6)
What is the purpose of the Read-only addition on the data statement in a
class definition?
- The read only addition is used to define a
public attribute with the data statement that can be read from outside the
class but can only be changed by methods of class itself.
7) What is the difference in attributes defined
in the public versus private section of a class?
- Public attributes are accessible by all
users of the class. Private attributes can only be accessed from with in the class itself.
8)
What is the keyword used to define static attributes?
- Class-data is used to define static
attributes.
9) What is the difference in an instance method
and a static method?
- An instance method can be called using an
instance and can use both static and instance components in the implementation.
Syntax: call method
instancename->instance-method_name.
An
static method can be called using the class and does not require an instance.
Syntax:
classname =>class_method_name.
Class
methods are similar to instance methods but can only use static components.
10) What statement is used to
instantiate an object?
-
Create
object is used to create an instance of a class in memory during runtime, this
is also
referred to as instantiation.
11) what is the purpose of garbage
collector?
-
The
garbage collector removes objects from memory and release the memory that no
longer have a reference pointing to it.
12) When is the constructor method is
executed?
-
A
constructor method is executed only once per instance and is automatically
called at runtime, When a create object statement is executed.
13) Is multiple inheritance is possible
in ABAP objects?
- No,
only single inheritance is supported. Single inheritance means that a subclass
can have one direct superclass.
14)
Static methods can be redefined ? -
No.
15)
A constructor method can be redefined? -
No.
16)
What is a redefined method?
- A redefined method is a method in a subclass
that provides a new definition of inherited method From a superclass in order
to provide a more specialized implementation in the subclass.
17)
What is a SUPER reference?
- The reference to super-> in the redefined
method is to call the original method of the superclass.
What are the type
casting methods and explain briefly?
18)
What is class?
- A class is a template/blueprint based on
which all objects of the class are created.
19) What is object? -
Object is an instance of a Class.
20) Can we instantiate a class
within implementation of other class?
- yes we can instantiate.
21) What is deferred key word ?
-
This is used in forward referencing.
CLASS class_name DEFINITION
DEFERRED.
22)
Can static method use instance attribute?
- No.
23) Can a method call itself?
- Yes.
24) What is preferred parameter?
- If there are more than one OPTIONAL import parameters in a method
and no non-optional import
parameters without values, one can type in the clause PREFERRED PARAMETER after the list of import parameters to specify
which of the optional parameters will get more preference compared to others
when the method will be called using syntax :-
CALL METHOD
objref->meth(<val>).
25) can we pass returing parameter by
reference ?
-
NO only
pass by value.
26)
What is ME variable?
- If an objects internally needs to
provide its own reference, it can use the local reference variable “ME”. “ME” is predefined and always
contains a reference to the address of its own object.
27) What are type of constructor and explain
them?
- Instance
constructor and static constructor.
Instance constructor can only have IMPORTING PARAMETERS &
EXCEPTIONS.
The Static constructor is called
automatically when the class is first accessed.
28)
Can we have export parameter in Instance constructor?
- It has no
EXPORTING parameters because its sole purpose is to initializing the object.
29)
Can instance constructor raise exception?
- Yes it can raise exceptions.
30)
Can we have static methods in interface?
- Yes.
31) What is interface?
- Interface is a declaration of a set of
methods with no information given about implementation of those methods.
32) Is it mandatory to implement all the
methods of interface?
- yes. Its mandatory.
33) What is
alias ?
- Instead of specifying full name of
interface methods we can assign it a name which can directly trigger.
34)
What is Friendship?
-
With the FRIEND relationship one class can grant another class or
interface ( and all classes that implement that interface ) access to its
PROTECTED and PRIVATE components.
35) Can
we have more than one event handler method for same event ?
-
yes. An event can have multiple event
handler method associate with it.
36) Can event have import
parameter ?
- No, The parameter interface for events is
limited to EXPORTING parameters,
passed by VALUE.
37) Can we call static constructor more than once
in a program?
-
Static constructor cannot be
called more than once in a program.
38)
How can we pass importing parameter ?
-
pass by value/pass by reference
39)
Can we implement interface in private section of any class?
- No we can’t.
40)
which of the following are correct ?
a)
Static
constructor can’t have interface parameters and can trigger exceptions
b)
Static
constructor can have interface parameters and can’t trigger exceptions
c)
Static
constructor can have interface parameters and can trigger exceptions
d)
Static
constructor can’t have interface parameters and can’t trigger exceptions
Subclasses of friend and interfaces that
receives a friend as a component interface become friend.
41)
Static attributes are visible in
all classes in the inheritance tree .
-
No.
42)
Can we put non declarative statement e.g. START-OF-SELECTION within a
class.
- No.
Dear ABAPers if you know any other OOABAP Interview Questions please share in below comment box.
"You found the information helpful and want to say thanks? Your donation is enough to inspire us to do more. Thanks a bunch!"
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.