1.
Kas yra klasės konstruktorius?
Correct Answer
C. Tai pirmasis klasės metodas, kuris yra kviečiamas konstruojant objektą.
Explanation
A class constructor is the first method in a class that is called when an object is being created. It is responsible for initializing the object and setting its initial state.
2.
Kiek argumentų būtina pateikti aprašant lokalų perkraunamą unarinį operatorių?
Correct Answer
A. Nereikia nei vieno
Explanation
No arguments are required to describe a local unary operator because a unary operator operates on a single operand. Therefore, it does not require any additional arguments to perform its operation.
3.
Klasės objekte naudojamas "const" metodas?
Correct Answer
B. Negali keisti klasėje deklaruotų duomenų, nesvarbu kurioje klasės prieigos srityje jie yra aprašomi.
Explanation
The "const" method used in a class cannot modify the data declared in the class, regardless of which access scope they are described in.
4.
"->" operatorius apjungia sekančius elementus (skaitant iš kairės į dešinę)
Correct Answer
D. Rodyklę į objektą ir klasės narį.
Explanation
The "->" operator is used to access a member of an object through a pointer. It is used to dereference the pointer and access the member of the object it is pointing to. In this case, the correct answer states that the "->" operator combines a pointer to an object and a member of that object, allowing access to the member through the pointer.
5.
Konstruktoriaus vardas yra tapatus
Correct Answer
B. Klasės vardui.
Explanation
The correct answer is "Klasės vardui" because the sentence "Konstruktoriaus vardas yra tapatus" translates to "The constructor's name is identical". In object-oriented programming, a constructor is a special method used to initialize objects. The name of the constructor is the same as the name of the class it belongs to. Therefore, the answer "Klasės vardui" means "For the class name" and is the most appropriate choice in this context.
6.
Bazinės klasės grynai virtualus metodas, tai metodas, kuris
Correct Answer
D. Privalo būti apibrėžtas visuose paveldėjimuose
Explanation
The correct answer is "Privalo būti apibrėžtas visuose paveldėjimuose" because a base class purely virtual method must be defined in all of its derived classes. This means that each derived class must provide its own implementation of the virtual method, ensuring that it is not left undefined and can be called correctly from any instance of the derived class.
7.
Kur yra klaida?
Correct Answer
B. Klaidų nėra
Explanation
The correct answer is "Klaidų nėra." This means that there are no errors in the given code or statement.
8.
Kur yra klaida?
Correct Answer
C. Neteisingas "obj_B.d_error = 2.36;" priskyrimas
Explanation
The incorrect assignment is "obj_B.d_error = 2.36;".
9.
Operacija "delete"
Correct Answer
A. Grąžina sistemai nenaudojamą dinaminę atmintį.
Explanation
The operation "delete" returns unused dynamic memory to the system. It can be used to deallocate memory that was previously allocated dynamically using the "new" operator. This helps in managing memory efficiently and preventing memory leaks. The other options mentioned in the question, such as destroying variables or initializing an array with zero elements, are not the main purpose of the "delete" operation.
10.
Jei bazinė ir paveldėjusi klasės naudoja metodus su tokiais pačiais vardais, tai paveldėjusios klasės objektas
Correct Answer
C. Naudos paveldėjusios klasės metodą, jei metodo naudojimas iš bazinės klasės neaprašytas :: operatoriumi.
Explanation
If a derived class inherits methods with the same names from both the base and derived classes, the object of the derived class will use the method from the derived class if the method usage is not specified in the base class using the :: operator.
11.
Klasės deklaracijoje naudojamas "private", tai
Correct Answer
B. Matomumo/prieigos srities specifikatorius
Explanation
The correct answer is "Matomumo/prieigos srities specifikatorius" (Visibility/access specifier). In class declaration, the "private" keyword is used to specify the visibility/accessibility of class members. It restricts the access to those members only within the class itself, and they cannot be accessed from outside the class. This keyword is used to enforce encapsulation and data hiding in object-oriented programming.
12.
"Draugiškos" ("friend") klasei funkcijos, tai
Correct Answer
A. Ne klasės narės funkcijos;
Explanation
The correct answer is "Ne klasės narės funkcijos" which translates to "Not member functions of the class". This is because the given options are describing different types of functions, and "Ne klasės narės funkcijos" is the only option that does not refer to functions that are part of the class. The other options refer to destructors, constructors, and member functions of the class.
13.
Grynai virtualus metodas - tai virtualus metodas, kuris
Correct Answer
A. Klasę padaro abstrakčia
Explanation
This statement explains that the virtual method "Grynai virtualus metodas" makes the class abstract. In object-oriented programming, an abstract class is a class that cannot be instantiated and is meant to be subclassed. It serves as a blueprint for other classes to inherit from. By making a method virtual, it allows the subclass to override the method and provide its own implementation. Therefore, by making the "Grynai virtualus metodas" virtual, the class becomes abstract.
14.
Virtualūs metodai:
Correct Answer
C. Negali būti konstruktoriais.
Explanation
Virtualūs metodai negali būti konstruktoriais, nes konstruktorius yra speciali klasės metodo rūšis, kuris naudojamas objekto inicijavimui ir jo inicializavimui. Virtualūs metodai yra skirti perrašyti (override) tėvo klasėje esančius to paties pavadinimo metodus vaikinėse klasėse. Taigi, virtualūs metodai negali būti naudojami objekto kūrimui ir inicializavimui, todėl negali būti konstruktoriais.
15.
"." operatorius (prieigos prie klasės nario operatorius) apjungia sekančius elementus (skaitant iš kairės į dešinę).
Correct Answer
D. Klasės objektą ir klasės narį.
Explanation
The "." operator (class member access operator) combines the class object and the class member.
16.
Objektas aprašytas "const" gali naudoti tik "const" metodus
Correct Answer
A. Teisingai
Explanation
This statement means that an object declared as "const" can only use methods that are also declared as "const". In other words, if an object is declared as "const", it cannot call any methods that modify the object's state or have side effects. This is because the "const" keyword indicates that the object should not be modified. Therefore, it is correct to say that an object declared as "const" can only use "const" methods.
17.
Kuris operatorius negali būti perkrautas?
Correct Answer
A. ?
Explanation
The question is asking which operator cannot be overloaded. The correct answer is "+". This means that the "+" operator cannot be overloaded in the given context. Overloading an operator means giving it a different behavior when used with certain types of operands. However, in this case, the "+" operator cannot be overloaded.
18.
Class Date {
...
Date (int, int, int) }
Kuris konstruktorius blogas?
Correct Answer
C. Date JustDate;
Explanation
The constructor for the Date class is incorrect for the object "JustDate". It is missing the assignment operator (=) after the constructor arguments, which means that the object "JustDate" is not being properly initialized with a specific date.
19.
Class A{};
class B{};
void main ()
{ A obj_A;
B obj_B;
obj_A=obj_B; }
Ar galimas toks kopijavimas?
Correct Answer
A. Ne
Explanation
In the given code, objects of class A and B are created. However, object obj_A of class A cannot be assigned the value of object obj_B of class B because they are of different types. The assignment operator (=) can only be used to assign values between objects of the same class or compatible types. Therefore, the given assignment is not possible, resulting in the answer "Ne" (No).
20.
Class A {
private:
int d;
static i_static = 10;
public :
A(){d=0;};
Inline int My () const {return d;}
void const_Your() {d++;}
}
Kur klaida?
Correct Answer
E. Bloga "static" kintamojo inicializacija
Explanation
The answer is "Bloga 'static' kintamojo inicializacija" because the static variable "i_static" is not properly initialized. It should be declared with a type and a semicolon after the declaration.