Basic Requirements For Polymorphism Quiz

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Darwinpv
D
Darwinpv
Community Contributor
Quizzes Created: 1 | Total Attempts: 229
| Attempts: 229 | Questions: 20
Please wait...
Question 1 / 20
0 %
0/100
Score 0/100
1. In ABAP Object there is a Garbage Collector?

Explanation

In ABAP Object, there is a Garbage Collector. This means that the programming language automatically manages the memory used by objects. The Garbage Collector identifies and removes objects that are no longer in use, freeing up memory and improving performance. This feature helps developers avoid memory leaks and ensures efficient memory allocation in ABAP Object programming.

Submit
Please wait...
About This Quiz
Basic Requirements For Polymorphism Quiz - Quiz

In computer programming, polymorphism is the provision of a single interface to entities of different types. Trust me, only tech nerds can get this language. If you are... see moreone, test your knowledge of the basic requirements for polymorphism below. see less

2. An abstract class cannot be instantiated. It specifies one or more abstract methods that must be implemented in a subclass. It is used as a means to enforce a uniform interface in subclasses, It is true?

Explanation

An abstract class cannot be instantiated because it is incomplete and serves as a blueprint for other classes to inherit from. It defines one or more abstract methods that must be implemented in the subclass, ensuring that all subclasses have a uniform interface. Therefore, the statement that an abstract class cannot be instantiated and is used to enforce a uniform interface in subclasses is true.

Submit
3. What is a (Instance) constructor? (Single Selection)

Explanation

An instance constructor is an instance method for initializing the attributes of an object. It is automatically called by the system during the creation of an object using the CREATE OBJECT statement. This constructor is responsible for setting the initial values of the object's attributes, ensuring that the object is in a valid state upon creation.

Submit
4. Can events be defined in interfaces?

Explanation

Events can be defined in interfaces. An interface in programming is a blueprint for classes to follow. It defines a set of methods and properties that a class implementing the interface must have. Events can be considered as a special type of property in an interface. They allow classes to subscribe to and handle specific actions or occurrences. By defining events in an interface, it ensures that any class implementing that interface will have the necessary event handlers.

Submit
5. The reference ME is defined by the system and has the folowing function (Single selection)

Explanation

The reference ME is used within a class to call attributes and methods of the class itself. This means that when using the reference ME, you can access and manipulate the attributes and methods that belong to the class in which it is being used. It is not used solely to reference the private methods or attributes of the class, but rather to interact with all the attributes and methods of the class.

Submit
6. Can events be triggered in interfaces?

Explanation

Events cannot be triggered in interfaces because interfaces only define the methods that a class implementing the interface must have, but they do not provide any implementation for those methods. Events, on the other hand, require an implementation to handle the event and trigger it. Therefore, events can only be triggered in classes that implement the interface, not in the interface itself.

Submit
7. For a user to be able to execute an object-oriented program, you always need to supply a module pool program or a function group program. Otherwise, there is nowhere for the CREATE OBJECT statement to create the instance.

Explanation

To execute an object-oriented program, it is not always necessary to supply a module pool program or a function group program. The CREATE OBJECT statement can create an instance of an object in various programming environments, including but not limited to module pool programs and function group programs. Therefore, the given statement is false.

Submit
8. Which of the following statements about inheritance are correct?

Explanation

The correct answer is that through inheritance, the public attributes of the super class are inherited to the subclass and the protected attributes of the super class are inherited to the subclass. This means that the subclass can access and use these attributes. However, the statement about private attributes is incorrect. Private attributes are not inherited to the subclass and cannot be directly addressed in the subclass using any specific syntax.

Submit
9. In the case of classes, we distinguish between two types of components (attributes and methods): Instance components and static components. Which of the following statements apply in this context?

Explanation

Instance methods can use both static as well as instance components in their implementation part. This means that within an instance method, we can access and manipulate both static attributes and instance attributes of a class.

Static methods can be called through the class using the "=>" syntax. This allows us to directly call a static method without having to create an instance of the class.

Static attributes exist only once for each class. This means that regardless of how many instances of a class are created, there will only be one instance of a static attribute shared among all instances of the class.

Submit
10. What is allowed within class definition? (T/F)

Explanation

The correct answer is the definition of Internal Tables without header lines and Typing with TYPE to ABAP Dictionary types.

Submit
11. Using the statement CREATE OBJECT  you can instantiate objects of a class. What situations can arise here?

Explanation

When using the statement "CREATE OBJECT", objects of a class are instantiated. This means that all objects of the same class will have the same number of attributes and methods once they are created. Additionally, it is possible to preset different objects of a class with different values immediately when they are being created. Finally, the type and number of attributes for an object are defined through the corresponding class.

Submit
12. Suppose you are copying a subclass reference to a reference variable that is typed to the superclass (narrowing cast). What components can you access with this reference variable?

Explanation

When copying a subclass reference to a reference variable typed to the superclass (narrowing cast), you can only access the redefined components of the superclass and the inherited components of the superclass. This means that you can access any components that have been overridden or redefined in the superclass, as well as any components that have been inherited from the superclass. You cannot access any newly defined components of the subclass, as they are not part of the superclass.

Submit
13. REF_CL is a reference to the class CL_DOCUMENT. REF_IF is a reference to the Interface IF_DISPLAY. The interface IF_DISPLAY is implemented by the class CL_DOCUMENT. What option do you have to create an object of the class CL_DOCUMENT?

Explanation

You can create an object of the class CL_DOCUMENT by using the following options:
1. CREATE OBJECT ref_cl: This creates an object of the class CL_DOCUMENT using the reference variable ref_cl.
2. CREATE OBJECT ref_if TYPE cl_document: This creates an object of the class CL_DOCUMENT using the reference variable ref_if and specifying the type as cl_document.
3. DATA class_name TYPE string. class_name = "CL_DOCUMENT". CREATE OBJECT ref_if TYPE (class_name): This creates an object of the class CL_DOCUMENT by dynamically assigning the class name to the variable class_name and then using it to specify the type of the object.
4. CREATE OBJECT ref_if: This creates an object of the class CL_DOCUMENT using the reference variable ref_if without specifying the type.

Submit
14. Which access authorizations apply to friend relationships?

Explanation

A friend of a class has access to both the public and private attributes of the class allowing the friendship. The friendship allows the friend to access the public attributes, while also granting access to the private attributes. It is important to note that the allowing of friendships is not inherited, meaning that subclasses of a friend class do not automatically gain access to the private attributes.

Submit
15. Which techniques are basic requirements for polymorphism? (T/F)

Explanation

The techniques that are basic requirements for polymorphism are narrowing cast, redefinition of methods (for polymorphism through inheritance), and implementation of methods of an interface in the respective classes (for polymorphism through inheritance). These techniques allow objects of different types to be treated as objects of a common type, enabling code to be written that can work with objects of different classes in a uniform way.

Submit
16. Which statements in connection with methods are correct?

Explanation

Methods in ABAP objects can be called in the same way as function modules. They are not restricted to only being called within ABAP Objects classes. Methods, like form routines or function modules, are used to modularize software. Additionally, similar to function modules, methods allow you to mark parameters as "optional".

Submit
17. Which of the following statements are correct? Choose the correct answer(s).

Explanation

A global class can contain a local class because local classes can be defined within methods or function modules of a global class. Similarly, a global class can also contain a local interface because interfaces can be defined within methods or function modules of a global class.

Submit
18. Which of the following statements about interfaces are correct? (T/F)

Explanation

Interfaces actually stand for an interface (protocol) between a client (interface user) and a server (implementing class). This means that interfaces define a contract that the implementing class must adhere to, ensuring that the client can interact with the server in a standardized way.

A client (caller) can use interface reference to access all methods of the Interfaces and thus achieve polymorphism behavior. This means that by using an interface reference, the client can treat different objects that implement the same interface in a uniform manner, allowing for flexibility and code reuse.

Using interfaces, you can simulate multiple inheritance. In languages that do not support multiple inheritance, interfaces provide a way to achieve similar functionality by allowing a class to implement multiple interfaces, inheriting the behavior defined in each interface.

Submit
19. Assume that a reference variable typed on a superclass contains a subclass reference and you copy this to a reference variable that is typed on the class (widening cast). Which of the following components can you access with this reference variable?

Explanation

When a reference variable typed on a superclass contains a subclass reference and is then copied to a reference variable typed on the class (widening cast), you can access the redefined components of the superclass, the newly defined components of the subclass, and the inherited components of the superclass. This is because the reference variable is now pointing to an object of the subclass, which inherits the components of the superclass and may also have additional components of its own. Therefore, all these components can be accessed using the reference variable.

Submit
20. SE24. If you have a "Singleton Pattern", you must ensure that only one object can be created from a CL_SINGLETON class. What mechanisms must you avail of here?

Explanation

To ensure that only one object can be created from a CL_SINGLETON class, the following mechanisms must be availed of:
1. The singleton class must have a class method implemented in which the CREATE OBJECT call is programmed for this one object.
2. The singleton class must have the addition CREATE PRIVATE in the definition part.
3. In the singleton class, there must be an event defined that is triggered when the first and only object is created and also prevents further objects of this class from being created.
4. The singleton class must have an instance method implemented in which the CREATE OBJECT call is programmed for this one object.
5. The CREATE OBJECT call for this one object can take place in the class constructor of the singleton class.

Submit
View My Results

Quiz Review Timeline (Updated): Mar 21, 2023 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 21, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Jan 20, 2010
    Quiz Created by
    Darwinpv
Cancel
  • All
    All (20)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
In ABAP Object there is a Garbage Collector?
An abstract class cannot be instantiated. It specifies one or more...
What is a (Instance) constructor? (Single Selection)
Can events be defined in interfaces?
The reference ME is defined by the system and has the folowing...
Can events be triggered in interfaces?
For a user to be able to execute an object-oriented program, you...
Which of the following statements about inheritance are correct?
In the case of classes, we distinguish between two types of components...
What is allowed within class definition? (T/F)
Using the statement CREATE OBJECT  you can instantiate objects of...
Suppose you are copying a subclass reference to a reference variable...
REF_CL is a reference to the class CL_DOCUMENT. REF_IF is a reference...
Which access authorizations apply to friend relationships?
Which techniques are basic requirements for polymorphism? (T/F)
Which statements in connection with methods are correct?
Which of the following statements are correct? ...
Which of the following statements about interfaces are correct? (T/F)
Assume that a reference variable typed on a superclass contains a...
SE24. If you have a "Singleton Pattern", you must ensure that only one...
Alert!

Advertisement