Você está na página 1de 7

1. What is the difference between Procedural and Object Oriented Programming ?

• In procedure oriented language data has not security but in object oriented data has
security.
• Procedure oriented programming gives importance to algorithm rather than data. It
follows Top-down structures.
• Object Oreinted Programming gives importance to data rather than algorithm. It follows
Bottom – Up structures.
• There is no access specifier in Procedural Programming and in OOP there are public,
private and protected specifier.
• OOPs includes features like data hiding polymorphism encapsulation and message
passing.

2. What are the advantage of ABAP OOPs?

•You can customize the Objects


• Already more Objects are predefined
• Stress on data security and access
• Data encapsulation and abstraction
• Reduction in code redundancy

3. What are the core ABAP OOPs Concept?

• Encapsulation

• Polymorphism

• Inheritance

4. What are the type of Object and Class?

• A class is a construct that is used as a blueprint (or template) to create Object of that
class.

• The state and behavior that the objects of the class all share.

• An object of a given class is called an instance of the class.

• The class that contains that instance can be considered as the type of that object, e.g. an
object instance of the "Fruit" class would be of the type "Fruit".
5. What are the type of Classes that can be created ?

• ABAP class

• Persistence Class

• Exception Class

6. What are the local and global classes?

• You define global classes and interfaces in the Class Builder (Transaction SE24) in the
ABAP Workbench.

• All ABAP programs have access to these 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.

7. What is a Reference Variable?

• Reference variables contain references. The actual contents of a reference variable,


namely the value of a reference, is not visible in an ABAP program.

• There are two kinds of data reference variables - data reference variables and object
reference variables.

8. What Components of an object you can access in the debugger?


• Attributes, Methods, Events, Interfaces of an object can be access in the debugger.

9. What are the Abstract class and Abstract Method?

• A class without a instance is abstract classes.

• Abstract classes are classes that contain one or more abstract methods.

• An abstract method is a method that is declared, but contains no implementation.

• Abstract classes may not be instantiated, and require subclasses to provide


implementations for the abstract methods.

10. What is the difference Between Abstract Method and Final Method?

• An abstract method is defined in an abstract class and cannot be implemented in that


class. It is implemented in a subclass of the class.

• A final method cannot be redefined in a subclass. Final classes cannot have subclasses.

11. What is a Super Class How it can be implemented?

• Inheritance is a relationship, in which one class (the subclass) inherits all the main
characteristics of another class (the superclass).
• The subclass can also add new components (attributes, methods, and so on) and replace
inherited methods with its own implementations.
• A super class is a generalization of its subclasses. The subclass in turn is a
specialization of its super classes.

12. What is a Narrow Casting? How can you implemented it?


• Narrow casting is used when we want to access the methods which are not present in the
superclass and that are present in the subclass.

• It can be implemented by using Sub class to the Super class.

13. What is a widening Casting?

• 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. Obviously it cannot be
statically checked, since an interface can be implemented by more than one class.

14. What is a singleton?

• Singleton will not able to create to an instance for already declared class.

• singleton is a classs in which at a time only one object can create.

15. What is a Constructor?

• Special method for creating objects with defined initial state.


• It'll be executed only once per instance.
• It has only Importing and Exception parameters.

16. What are the limitations of redefining a method?

• To implement a redefined method in a subclass, you often need to call the method of the
same name in the immediate super class.

17. What are Static Components? What Component Selector.

• The contents of static Component define the state of the class that is valid for all instances
of the class. Static component exist once for each class.
• They are accessible for the entire runtime of the class.

18. What are instance Components?

• The contents of Instance Component define the instance state of the class that is valid for that
particular instance of the class.
• Instance component will be vary along the entire class.

19. How Encapsulation is implemented in OOPs?

• Encapsulation can be Implemented by three vissiblity mechanism.


• Public section, components which we declared in this section it will be accessible in any
Class.
• Protected section, components which we declared in this section it will be accessible by
its class and by its sub-classes.
• Private section, components which we declared in this section it will be accessible in the
methods of the same class only.

20. What are Interface? What are the Advantage of Interface?

• Interfaces will be act as a tool to inherit the behaviour of various classes in a single calss.
• Modify the Interface will modify the functionality wherever it has been used.
• Multi Inheritance can be possible using this Interfaces.

21. How can an Event be raised and handled?

• Event can be raised,when an object or class announces a change of state, or that a certain
state has been achieved.
• A class or instance can trigger an event at runtime using the RAISE EVENT statement.

22. What are the Exception? How can an Exception be raised?

• When there is no point in continuing to run the program in the normal way
then the Exceptions will occur.
• Exceptions are raised either using the ABAP statement RAISE EXCEPTION or
by the ABAP runtime environment.

23. What are the types of Exception Classes?

• Types of Exception classes are Checked, Unchecked and Error classes.

24. What are the Exception? How can an Exception be raised?

• Protected method can be accessed only by its class and its sub-classes.

25. What is a signature of a method?


• Methods can have IMPORTING, EXPORTING, CHANGING, and RETURNING
parameters as well as exception parameters. All parameters can be passed by value or
reference.

26. Syntax to find out if a reference variable is referring to an object?

The Syntax for the reference variable is described as below:

IF Ref_Var IS BOUND.

ENDIF.

Ref_Var is a reference variable. The above condition describes whether that reference
variable is referring to valid reference or not.

27. What is a Alias in ABAP OOPs?

• Alias names can only appear in the in the declaration part of a class or in the interface
definition.
• An alias defined in this way can be directly addressed using r_ref->a1.

28. What is a Functional Method?

When defining:
• Only one RETURNING parameter
• Only IMPORTING parameters and exceptions are possible

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

• The Garbage Collector is a system routine that automatically deletes objects that can no
longer be addressed from the main memory and releases the memory space they
occupied.

30. What is a Static Constructor? What are the advantages?

• The static constructor is a special static method in a class with the name Constructor name. It
is executed precisely once per program. The static constructor of a class is called
automatically when the class is first accessed, but before any of the following actions are
executed:
• Creating an instance in the class using CREATE OBJECT <obj>, where <obj> has the
data : type REF TO <classname>
• Addressing a static attribute using <classname>=><attribute>
• Calling a static attribute using CALL METHOD <classname>=><classmethod>
• Registering a static event handler method using SET HANDLER
• <classname>=><handler_method> FOR <obj>
• Registering an event handler method for a static event in class <classname>.
• The static constructor cannot be called explicitly.
31. What is a private Constructor? Limitations?

• When you declare a Constructor with Private access modifier then it is called Private
Constructor.
• We can use the private constructor in singleton pattern.
• If you declare a Constructor as private then it doesn’t allow to create object for its derived
class

32. Can a Class be defined Without a Constructor?


• Yes, We can declare a class without a Constructor.
• Class will be initiated automatically without a constructor.

33. What is a friend class?

• A class can provide friendship to other classes and interfaces (and hence all classes
that implement the interface). To do this you use the FRIENDS additions to the
CLASS statement, in which all classes and interfaces that are to be provided
friendship are listed.
• Friends are allowed to access the protected and private components of the class
providing the friendship and can always create instances of this class, regardless of the
CREATE addition to the CLASS statement.

34. Explain Syntax “type table of ref to”?

itab TYPE TABLE OF REF TO lcl_vehicle.


Itab describe the internal table which refer to the type of the class name.

35. Can I pass an internal table through Importing parameter of a method ?

Yes. We can pass an Internal table through Importing parameter of a Method.


36. Structure of a Local Class Definition ?

The following statements define the structure of a class:

• A class contains components

• Each component is assigned to a visibility section

• Classes implement methods

Você também pode gostar