Saturday, February 2, 2013

SAP-OOABAP-Inheritance-Interview-Questions-Answers

SAP-ABAP Inheritance Interview Questions Answers, Inheritance is the main feature of Object Oriented Programming in any Object Oriented Language, like OOABAP also contains Inheritance feature to extend the functionality of language of SAP-ABAP. Here in this post we are going to provide list of interview questions and also answers on Inheritance topic. These questions are very frequently asked by the interviewers in the interviews. Click on read more to refer this post.


 SAP-OOABAP-Inheritance-Interview-Questions-Answers


SAP-ABAP Inheritance Interview Questions Answers, Inheritance is the main feature of Object Oriented Programming in any Object Oriented Language, like OOABAP also contains Inheritance feature to extend the functionality of language of SAP-ABAP. Here in this post we are going to provide list of interview questions and also answers on Inheritance topic. These questions are very frequently asked by the interviewers in the interviews. 



1) What is inheritance?

Ans) 

Inheritance allows you to derive a new class from an existing class. You do this using the INHERITING FROM addition in the CLASS subclass DEFINITION INHERITING FROM superclass statement.



2) What are the visibility sections visible to subclass of superclass?

Ans) 

Only the public and protected components of the superclass are   visible in the subclass.


3) Can we declare same name for components of subclass as components of super class?

Ans) 

Subclasses contain all of the components of all of their superclasses within the inheritance tree. Only the public and protected ones are visible. All public and protected components within an inheritance tree belong to the same namespace, and consequently must have unique names. The names of private components, on the other hand, must only be unique within their class.


4) What is single inheritance?

Ans) 

A class can have more than one direct subclass, but it may only have one direct superclass. This is called single inheritance.


5) Does OOABAP supports multiple inheritance?

Ans) 

No, OOABAP does not support multiple inheritance but it supports multi level inheritance.


6) What is the root node of all inheritance trees?

Ans) 

The root node of all inheritance trees in ABAP Objects is the predefined empty class OBJECT. This is the most generalized class possible, since it contains neither attributes nor methods. 

When you define a new class, you do not have to specify it explicitly as the super class - the relationship is always implicitly defined.


7) How can we re-implement super class method in subclass?

Ans) 

Super class method can be re-implemented in the derived class using redefinition key word.



8) Can we change the parameter interface of the redefined methods?

Ans) 

No, we cannot change the parameter interface of the redefined methods.



9) How to call original method from redefined method?

Ans) 

In the redefined method use the SUPER-> pseudo reference to access the original method of the base class.



10) What is an abstract class?


Ans) 

A class defined as ABSTRACT cannot be instantiated, that is one cannot use CREATE OBJECT with reference to the class. To use the instance components of an abstract class, a subclass of the class must be instantiated.



11) Can abstract methods be redefined?

Ans) 

Yes, abstract methods should be redefined in the subclass. Else it gives syntax error. If subclass is also abstract classes then no need to redefine the abstract method.



12) Can final class methods be redefined in the subclass?

Ans) 

A final method cannot be redefined in a subclass. Final classes cannot have sub classes. They conclude an inheritance tree.


13) Can static method be redefined?

Ans) No, static methods cannot be redefined.



14) Can we change the visibility of the redefined method?

Ans) 

No, we cannot change the visibility of the redefined method. That is , if method is defined in super class in public section then we cannot redefine the same method in the subclass under protected or private.



15) Can the private and protected classes can be inherited?

Ans) 

Yes, we can inherit the private and protected classes. Then the subclass itself becomes the private or protected class.



16) Does the instantiation of Subclass depend on the super class?

Ans) 

Where a subclass can be instantiated depends on its immediate super class:


                    i. Immediate sub classes of object, or classes with the CREATE PUBLIC addition implicitly inherit the CREATE PUBLIC addition. All CREATE additions that overwrite the inherited addition can be specified explicitly.

                  ii.  Immediate sub classes of classes with the CREATE PROTECTED addition implicitly inherit the CREATE PROTECTED addition. All CREATE additions that overwrite the inherited addition can be specified explicitly.


                iii.   Immediate sub classes of classes with the CREATE PRIVATE addition that are not friends of the class implicitly receive the CREATE NONE addition. They cannot be instantiated and you cannot specify any explicit CREATE additions for them.


                iv.  Immediate sub classes that are friends of the class implicitly inherit the CREATE PRIVATE addition. All CREATE additions can be specified for all super classes that can instantiated as private using friends.


17) Can the constructor be redefined?

Ans)  

No, we cannot redefine the instance constructor of a super class in a subclass, neither can you call one specifically using the statement CALL METHOD CONSTRUCTOR.



18) Does the parameter interface of the instance constructor be changed in the subclass?

Ans) 

The parameter interface for instance constructor of each class may be different in an inheritance tree.


19) Do we need to call the super class instance constructor in the subclass when instance constructor is redefined?

Ans)  

During implementation of redefined instance constructor in derived class , the instance constructor of the super class must be called with the 

CALL METHOD SUPER->constructor … EXPORTING … statement.



20) In which order the constructors execute in inheritance tree?

Ans) 

The first time a subclass is addressed in a program, the run time environment reaches for the next highest super class whose constructor has not yet been executed. 

This constructor is executed first, followed by constructors down the path until the addressed subclass is reached.



21) Can we call the instance constructor of the super class in sub class?

Ans) 

Yes, we can call the instance constructor of the super class explicitly in subclass instance constructor using  Pseudo reference (SUPER->).

This is the only place where we call the constructor explicitly.



22) Can we call the static constructor of the super class in sub class?

Ans) 

NO, we cannot call the static constructor explicitly. The runtime environment automatically ensures that the static constructors are called in the right order, so it is not required to call the static constructor of the super class explicitly.



23) What is polymorphism?


Ans) 

When objects from different classes react differently to the same method calls, this is know as polymorphism.  This is achieved through inheritance and interfaces.



24)  What is Narrowing cast(Upcast)? Explain briefly?

Ans)

Assigning sub class reference to super class reference. Syntax for narrowing cast is ‘=’ or ‘MOVE’ …‘TO’. If you assign a sub class reference to a super class reference, this ensures that all components that can be accessed syntactically after the cast assignment are actually available in the instance. 

The subclass always contains at least the same components as the super class.



25) What is the use of Narrowing cast?

Ans) 

Typical use of narrowing cast assignment is to prepare for generic access. A user who is not at all interested in the finer points of the instances of the sub classes but who simply wants to address the shared components could use a super class reference for this access.



26) Which components of sub class can be accessed from super class reference using narrowing cast?

Ans) 

Only the inherited components can be accessed from super class reference after narrowing cast.



27) What is Widening cast ( Down casting)?

Ans) 

Assigning super class reference to sub class reference. Syntax  for widening cast is ‘?=’ or ‘MOVE’…’?TO’. 



28) What is the use of Widening cast?

Ans) 

Typical use of for widening cast assignments is when specific components of instances need to be addressed and their references are kept in variables that are typed on the super class. 

A user who is interested in the finer points of the instances of a subclass cannot use the super class reference for this access because it only allows access to the shared components.




Dear ABAPers if you know any other questions please share your views 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.

Categories

ABAP (1) ABAP Interview Questions (112) ABAP Open SQL Statements (1) ABAP Syntax Rules (6) ABAP WORKBENCH (2) ABAP-Interview-Questions (52) ALE IDOC (6) ALE IDOC Interview Questions (6) ale-idoc (6) ALE-IDOC-Interview-Questions (19) ALV Interview Questions (5) ALV-Interview-Questions (22) BADI (2) BAPI (1) BAPI Interview Questions (1) BAPI-Interview-Questions (14) BDC (6) BDC Interview Questions (6) BDC-Interview-Questions (9) big data (2) big data interview questions (1) Classical Reports Interview Question (3) Classical-Reports-Interview-Questions (22) Conditional Statements (1) Cross Applications (3) Cross-Applications (14) Data Dictionary (22) Data Type Questins (1) Data types (1) Data-Dictionary (48) Data-Type-Questins (6) Dialog programming (5) Dialog Programming Interview Questions (4) Dialog-Programming (30) DOMAIN Interview Questions (1) Domain-Interview-Questions (8) Function Module (2) hadoop (2) hadoop interview questions (2) hdfs (1) IDoc Tutorials (6) Interactive Report Interview Questions (4) Interactive-Reports-Interview-Questions (22) Internal Tables (1) interview questions (1) Lock Object Interview Questions (1) Lock-Objects-Interview-Questions (10) Logical Database (1) Modularization Interview Questions (4) Modularization-Interview-Questions (25) Module Pool Programming (5) Module-Pool-Programming (39) modules in sap (1) Object Oriented ABAP (19) Object Oriented ABAP Interview Questions (15) object-oriented-abap (2) Object-Oriented-ABAP-Interview-Questions (34) OOABAP (9) Reports (14) Reports Interview Questions (9) Reports-Interview-Questions (19) RFC (1) RFC Interview Questions (1) RFC-Interview-Questions (14) RICEF (1) RICEF Objects (1) SAP (4) SAP ABAP (4) SAP ABAP Interview Questions (42) SAP ABAP Introduction (46) SAP ABAP Message Types (2) SAP BADI Interview Questions (2) SAP Basics (71) SAP Books (2) SAP Certification (1) SAP CONSULTANTS (5) SAP CRM (1) SAP ENHANCEMENTS (3) SAP EXITS (2) SAP EXITS ( SAP ENHANCEMENTS ) Interview Questions (1) SAP Free Books (1) SAP HR (2) SAP Lock Object (1) sap modules (2) SAP Open SQL Statements (1) SAP R/3 Architecture (4) SAP Search help (1) SAP Smartforms (1) SAP Smartforms Interview Questions (2) SAP Tables (5) SAP Tcodes (10) SAP Views (1) SAP Webdynpro ABAP (12) SAP Work Processors (2) SAP Workflow (3) SAP-BADI-Interview-Questions (11) SAP-Enhancements (39) SAP-Exits (39) SAP-Exits-Enhancements-Interview Questions (3) SAP-HANA (1) SAP-HANA-Interview-Questions (1) SAP-Smartforms-Interview-Questions (2) SAP-Workflow (3) Scripts (3) Scripts Interview Questions (2) Scripts-Interview-Questions (32) Search Help Interview Questions (1) Search-Help-Interview-Questions (9) Smartforms (1) Table Maintenance Generator (1) Table-Maintenance-Generator (4) Tables in SAP (2) Tables Interview Questions (3) Tables-Interview-Questions (3) Type Group Interview Questions (1) Type-Group-Interview-Questions (7) Variable Declaration (1) Views Interview Questions (1) Views-Interview-Questions (5) Webdynpro (12) what is big data (1)

Protected Blog

 
This blog is not affiliated to SAP AG |SAP is trademark of SAP AG |The information collected from various sources use information with your own risk.