1.
What is allowed within class definition? (T/F)
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.
2.
Which techniques are basic requirements for polymorphism? (T/F)
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.
3.
Which of the following statements about interfaces are correct? (T/F)
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.
4.
Using the statement CREATE OBJECT you can instantiate objects of a class. What situations can arise here?
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.
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?
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.
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?
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.
7.
Which access authorizations apply to friend relationships?
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.
8.
Which statements in connection with methods are correct?
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".
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?
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.
10.
The reference ME is defined by the system and has the folowing function (Single selection)
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.
11.
Which of the following statements about inheritance are correct?
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.
12.
What is a (Instance) constructor? (Single Selection)
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.
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?
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.
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?
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.
15.
Can events be defined in interfaces?
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.
16.
Can events be triggered in interfaces?
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.
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.
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.
18.
Which of the following statements are correct?
Choose the correct answer(s).
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.
19.
In ABAP Object there is a Garbage Collector?
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.
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?
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.