Basic Requirements For Polymorphism Quiz

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Darwinpv
D
Darwinpv
Community Contributor
Quizzes Created: 1 | Total Attempts: 194
Questions: 20 | Attempts: 194

SettingsSettingsSettings
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 one, test your knowledge of the basic requirements for polymorphism below.


Questions and Answers
  • 1. 

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

    • A.

      Typing with LIKE to ABAP Dictionary types.

    • B.

      The definition of Internal Tables with header lines.

    • C.

      The TABLES statement.

    • D.

      The definition of Internal Tables without header lines.

    • E.

      Typing with TYPE to ABAP Dictionary types.

    Correct Answer(s)
    D. The definition of Internal Tables without header lines.
    E. Typing with TYPE to ABAP Dictionary types.
    Explanation
    The correct answer is the definition of Internal Tables without header lines and Typing with TYPE to ABAP Dictionary types.

    Rate this question:

  • 2. 

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

    • A.

      Narrowing Cast.

    • B.

      Redefinition of methods (for polymorphism through inheritance).

    • C.

      Widening Cast.

    • D.

      Implementation of methods of an insterface in the respective classes (for polymorphism through inheritance).

    Correct Answer(s)
    A. Narrowing Cast.
    B. Redefinition of methods (for polymorphism through inheritance).
    D. Implementation of methods of an insterface in the respective classes (for polymorphism through inheritance).
    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.

    Rate this question:

  • 3. 

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

    • A.

      Interfaces actually stand for an interface (protocol) between a client (interface user) and a server (implementing class).

    • B.

      Interfaces are used to call static components of a class.

    • C.

      Using interface references you can reference all the public components of an object that have been defined in the corresponding interface-implementing class.

    • D.

      A client (caller) can use inteface reference to access all methods of the Interfaces and thus archive polymorphism behavior.

    • E.

      Using interfaces you can simulate multiples inheritance.

    Correct Answer(s)
    A. Interfaces actually stand for an interface (protocol) between a client (interface user) and a server (implementing class).
    D. A client (caller) can use inteface reference to access all methods of the Interfaces and thus archive polymorphism behavior.
    E. Using interfaces you can simulate multiples inheritance.
    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.

    Rate this question:

  • 4. 

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

    • A.

      All objects of the same class contain the same number of attributes and methods after being created.

    • B.

      You can preset different objects of a class with different values inmediately when they are being created.

    • C.

      The contents of the attributes of different objects in a class always contain the same content or value inmediately after being created.

    • D.

      You define the type and number of attributes of an object through the correspoding class.

    Correct Answer(s)
    A. All objects of the same class contain the same number of attributes and methods after being created.
    B. You can preset different objects of a class with different values inmediately when they are being created.
    D. You define the type and number of attributes of an object through the correspoding class.
    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.

    Rate this question:

  • 5. 

    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?

    • A.

      CREATE OBJECT ref_cl.

    • B.

      CREATE OBJECT ref_if TYPE cl_document.

    • C.

      DATA class_name TYPE string. class_name = "CL_DOCUMENT". CREATE OBJECT ref_if TYPE (class_name).

    • D.

      CREATE OBJECT ref_if.

    Correct Answer(s)
    A. CREATE OBJECT ref_cl.
    B. CREATE OBJECT ref_if TYPE cl_document.
    C. DATA class_name TYPE string. class_name = "CL_DOCUMENT". CREATE OBJECT ref_if TYPE (class_name).
    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.

    Rate this question:

  • 6. 

    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?

    • A.

      In a static method, Instance attributes can also be used, provided they area declared as READ ONLY.

    • B.

      Instance methods can use both static as well as instance components in their implementation part.

    • C.

      Both static as well as Instance attributes are declared using the DATA statement.

    • D.

      Static methods can be called through the class: =>.

    • E.

      Static attributes exist only once for each class.

    Correct Answer(s)
    B. Instance methods can use both static as well as instance components in their implementation part.
    D. Static methods can be called through the class: =>.
    E. Static attributes exist only once for each class.
    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.

    Rate this question:

  • 7. 

    Which access authorizations apply to friend relationships?

    • A.

      A friend of a class access to the public attributes of the class allowing the friendship.

    • B.

      A subclass of a friend class has automatic access to the private attributes of the class allowing the friendship.

    • C.

      A friend of a class has access to the private attributes of the class allowing the friendship.

    • D.

      The allowing of a friendships is not inherited.

    Correct Answer(s)
    A. A friend of a class access to the public attributes of the class allowing the friendship.
    C. A friend of a class has access to the private attributes of the class allowing the friendship.
    D. The allowing of a friendships is not inherited.
    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.

    Rate this question:

  • 8. 

    Which statements in connection with methods are correct?

    • A.

      You can call methods in ABAP objects in the same way as function modules.

    • B.

      You can call methods only within ABAP Objects classes.

    • C.

      Like form routines or function modules, methods are a means to modularize software.

    • D.

      Similar to the case with function modules, you hace the option with methods of marking parameters as "optional".

    Correct Answer(s)
    C. Like form routines or function modules, methods are a means to modularize software.
    D. Similar to the case with function modules, you hace the option with methods of marking parameters as "optional".
    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".

    Rate this question:

  • 9. 

    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?

    • A.

      The singleton class must have a class method implemented in which the CREATE OBJECT call is programmed for this one object.

    • B.

      The singleton class must hace the addition CREATE PRIVATE in the definition part.

    • C.

      In the singleton class, there must be an even defined that is triggered when the first and only object is created and also prevents further objects of this class from being created.

    • D.

      The singleton class must have an instance method implemented in which the CREATE OBJECT call is programmed for this one object.

    • E.

      The CREATE OBJECT call for this one object can take place in the class constructor of the singleton class.

    Correct Answer(s)
    A. The singleton class must have a class method implemented in which the CREATE OBJECT call is programmed for this one object.
    B. The singleton class must hace the addition CREATE PRIVATE in the definition part.
    C. In the singleton class, there must be an even defined that is triggered when the first and only object is created and also prevents further objects of this class from being created.
    D. The singleton class must have an instance method implemented in which the CREATE OBJECT call is programmed for this one object.
    E. The CREATE OBJECT call for this one object can take place in the class constructor of the singleton class.
    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.

    Rate this question:

  • 10. 

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

    • A.

      You use the reference ME within a class solely to reference the private methods of the class itself.

    • B.

      You use the reference ME within a class to call attributes and methods of the class itself.

    • C.

      You use the reference ME within a class solely to reference the private attributes of the class itself.

    Correct Answer
    B. You use the reference ME within a class to call attributes and methods of the class itself.
    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.

    Rate this question:

  • 11. 

    Which of the following statements about inheritance are correct?

    • A.

      Through inheritance, the public attributes of the super class are inherited to the subclass.

    • B.

      Through inheritance, the private attributes of the super class are inherited to the subclass and they can be addressed in the subclass directly using "ME->".

    • C.

      Through inheritance, the protected attributes of the super class are inherited to the subclass.

    • D.

      Through inheritance, the private attributes of the super class are inherited to the subclass and they can be addressed in the subclass directly using "THIS->"

    Correct Answer(s)
    A. Through inheritance, the public attributes of the super class are inherited to the subclass.
    C. Through inheritance, the protected attributes of the super class are inherited to the subclass.
    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.

    Rate this question:

  • 12. 

    What is a (Instance) constructor? (Single Selection)

    • A.

      An instance attribute that is automatically given a unique identification by the system when an object is created.

    • B.

      An instance method for initializing the attributes of an object; it is automatically called by the system during CREATE OBJECT.

    • C.

      An instance method for controlling how much main memory is to be reserved for an object.

    Correct Answer
    B. An instance method for initializing the attributes of an object; it is automatically called by the system during CREATE OBJECT.
    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.

    Rate this question:

  • 13. 

    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?

    • A.

      Redefined components of the superclass

    • B.

      Newly defined components of the subclass

    • C.

      Inherited components of the superclass

    • D.

      Redefined components of the subclass

    Correct Answer(s)
    A. Redefined components of the superclass
    C. Inherited components of the superclass
    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.

    Rate this question:

  • 14. 

    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?

    • A.

      Redefined components of the superclass

    • B.

      Newly defined components of the subclass

    • C.

      Inherited components of the superclass

    • D.

      Redefined components of the subclass

    Correct Answer(s)
    A. Redefined components of the superclass
    B. Newly defined components of the subclass
    C. Inherited components of the superclass
    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.

    Rate this question:

  • 15. 

    Can events be defined in interfaces?

    • A.

      YES

    • B.

      NO

    Correct Answer
    A. YES
    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.

    Rate this question:

  • 16. 

    Can events be triggered in interfaces?

    • A.

      YES

    • B.

      NO

    Correct Answer
    B. NO
    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.

    Rate this question:

  • 17. 

    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.

    • A.

      TRUE

    • B.

      FALSE

    Correct Answer
    B. FALSE
    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.

    Rate this question:

  • 18. 

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

    • A.

      You can create function modules using the Class Builder.

    • B.

      A global class can contain a local class.

    • C.

      A global interface can contain a local interface.

    • D.

      A global class can contain a local interface.

    • E.

      A nested definition of classes is when a local class is within a global class.

    Correct Answer(s)
    B. A global class can contain a local class.
    D. A global class can contain a local interface.
    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.

    Rate this question:

  • 19. 

    In ABAP Object there is a Garbage Collector?

    • A.

      TRUE

    • B.

      FALSE

    Correct Answer
    A. TRUE
    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.

    Rate this question:

  • 20. 

    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?

    • A.

      TRUE

    • B.

      FALSE

    Correct Answer
    A. 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.

    Rate this question:

Related Topics

Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.