TesteLicentaEngleza 2018 2
TesteLicentaEngleza 2018 2
Note:
The written test of the graduation exam (July or September 2018) will consist of 60 questions
which will be similar (in structure and difficulty level) with those included in this booklet. For
each of the three categories (Discrete Structures and Algorithms, Programming Languages
and Software Engineering, Computing Systems and Databases) there will be 20 questions.
If there are unclear aspects concerning the questions and/or answers please contact the
teacher(s) who proposed the questions for each section:
C Programming Language:
Software Engineering:
1
1 C LANGUAGE
1 C Language
1. The value of
!b || (a && b)
char c;
(c=getchar()) != EOF
int a=2;
square(a);
...
2
1 C LANGUAGE
(c) the definition of square does not serve the purpose of squaring the actual argument in the
caller function
(d) the definition of square is formally correct
5. Assuming 32-bit addresses, how many bytes of memory will be reserved by the following decla-
rations?
(a) 12 bytes
(b) 8 bytes
(c) 4 bytes
(d) none
6. Assuming the appropriate function prototypes are available, what’s wrong with the sequence:
int *pi;
char *pc;
scanf("%d", pi);
strcpy(pc, "Timisoara");
7. Knowing that the . and the -¿ operator have equal precedence, higher than the precedence of the
* operator and assuming the following declarations, which of the expressions bellow are correct?
3
1 C LANGUAGE
struct point {
int x, y;
};
struct rectangle{
struct point p1, p2;
} *r[N];
(a) r[i].p1.x
(b) r[i]->p1.x
(c) (*r[i]).p1.x
(d) *r[i].p1.x
9. Which of the following are means of communication (sharing of data) between functions?
10. Which of the following storage classes is implicit, due to the place of the variable’s declaration:
(a) static
(b) auto
(c) register
(d) extern
11. The result of executing the following two sequences of statements is:
(a) different
4
1 C LANGUAGE
(b) identical
(c) context-dependent
12. Can two functions, neither of whom calls the other, communicate (share data)?
(a) no
(b) yes, through messages
(c) eventually, through global variables
and assuming that neither i nor t are explicitly initialized, the value of the expression
(a) is 1
(b) is 0
(c) it depends on the context
(a) 4
(b) 3.5
(c) of type double
(d) of type float
16. Given float x=2.5; the value of the expression 3.0*x+10/4 is:
(a) 10.0
(b) 9.5
5
1 C LANGUAGE
18. How many times will the while loop below be iterated through?
struct {
int a:2;
int b:5;
} v;
v.a=v.b=0;
while(v.a != 3)
v.b = 2*v.a++;
20. Knowing that, by default, data of integer types are signed, which is the value of c after: char
c=48;
(a) ’
0’
(b) -208
(c) 0x30
(d) 48
(a) ’0’
6
1 C LANGUAGE
(b) 0x0
(c) 0
(d) ’\\0’
(e) NULL
(f) "FALSE"
(a) yes
(b) no
(c) only if it is the first member
(d) only if it is the last member
(a) char
(b) double
(c) short
(d) int
(e) byte
(f) long
26. Knowing that ”0123456789” is the memory address where the string constant is generated, which
is the result of evaluating the expression: ”0123456789”[i] if i=10?
7
1 C LANGUAGE
(c) ’
0’
(d) of type char
(a<=’a’) | (’z’<= a)
(a) 0
(b) 1
(c) it depends on the value of a
(a) 0
(b) 1
(c) it depends on the value of a
(a) 19
(b) 20
(c) t[19 ]- t[0]
(d) It is illegal to substract a pointer from another pointer!
8
2 C++ LANGUAGE
2 C++ Language
1. In C++, a constructor is a function that has the following properties:
(a) Is a member function that has the same name like the class in which it is declared
(b) Is a member function that returns a value
(c) Is a member function that does not return a value
(d) Is a member function that never has parameters
(e) Is a member function used to initialize an object
(f) Is a member function used to deallocate memory space
(g) Is a member function that is used together with new operator
(h) A class can have only one constructor
(i) It is a method that is called by delete operator
(j) Can be a virtual function
2. Which of the following features are supported by C++ language and not supported by C lan-
guage?
3. If a and b are two objects of type class Test and the class contains a function with the following
prototype: static bool equals(const Test&, const Test&);. Which is the correct call for function
equals() from a function outside class definition?
(a) equals(a,b);
(b) a.equals(b);
(c) Test.equals(a,b);
(d) a.equals(b,a);
(e) equals(b);
9
2 C++ LANGUAGE
(a) In C++ and Java languages does not matter the order of member function definition.
(b) In C++ and Java languages the comments may be specified in the same way.
(c) In case of exception handling with try-catch mechanism in Java and C++ languages, there
exists a clause that is executed in all cases (if an error is thrown or not).
(d) In C++ and Java languages a superclass for all classes exists.
(e) Class declaration in both C++ and Java languages finish with semicolon(;).
(f) In C++ language all methods must to be defined inside class body.
(a) Template is a feature of C++ that allows us to write one code for different data types.
(b) We can write one function that can be used for all data types including user defined types.
Like sort(), max(), min(), ..etc.
(c) We can write one class or struct that can be used for all data types including user defined
types. Like Linked List, Stack, Queue ..etc.
(d) Template is an example of compile time polymorphism.
8. If a class X has pointer variable members, then the class should contain:
10
2 C++ LANGUAGE
11. Which is the correct order of constructor and destructor call in the following code?
class B { public: B(){}};
class M : public B { public: M(){}};
class N: protected B { public: N(){}};
class D: public N, protected M { public: D() : M(), N() {}};
int main() {
D obj;
return 0;
}
(a) Constructor: B N B M D (b) Constructor: B M B N D
Destructor: B N B M D Destructor: D N B M B
(d) Constructor: D
(c) Constructor: B N B M D Destructor: D
Destructor: D M B N B
(e) Constructor: B N M D (f) Constructor: B N B M D
Destructor: D M N B Destructor: D N B M B
11
2 C++ LANGUAGE
12
2 C++ LANGUAGE
13
2 C++ LANGUAGE
14
2 C++ LANGUAGE
17. Which of the following line invokes the base constructor of Employee class in C++?
(a) both, because the pointers to base/derived class can be initialized in both cases
(b) none, because the pointer type does not correspond to the type of the object that it is pointing
15
2 C++ LANGUAGE
21. For the following declaration, how can member Counter be accessed without creating a instance
of class Foo?
struct Foo { (a) Foo().Counter
static int Counter;
Foo(const Foo &f); (b) Foo.Counter
Foo();
(c) Foo-> Counter
};
(d) Foo::Counter
(e) ::Counter
22. For class Foo declaration and foo() function, which of the following statements are true?
struct Foo { (a) The copy constructor would be invoked
static int Counter; only if f (right value) would be a constant
Foo(const Foo &f); object.
Foo();
}; (b) The assignment is automatically generated
void foo() { and it is used.
Foo f;
Foo f2 = f; (c) The copy constructor is called when object
} f2 is initialized.
23. When member functions of base class does not have sense in context of a derived class, the cause
is the violation of the following OPP principle:
(a) OCP
(b) SRP
(c) LSP
(d) DRY
16
2 C++ LANGUAGE
void f(int a) {
static int x = 100;
cout << x << " ";
if(a>0) {
static int y = 5;
cout << y+x << " ";
}
x = 200;
cout << x << " ";
}
25. Let class Employee be the base class for different types of employees of an institution. Which
statement is true with regards to line labelled with (1) in the following code?
void f(vector<Employee*> v) { (a) The function print() from derived class will
for(int i=0; i<v.size(); i+) always be called.
v[i]->print(); (1)
} (b) The function print() from derived class will
// vector is a class from C++ always be called only if the print() function
//standard template library is declared virtual in class Employee.
17
2 C++ LANGUAGE
(a) In case of class templates, the compiler will generate code for all declared templates, no
matter if they are instantiated or not
(b) In case of template functions, the code will be generated just when they are called
(c) The errors in templates declaration can be identified at compilation time
(d) There can be errors in template declarations that are discovered just when the template is
initialized
(e) A non-type parameter of a template, e. g. template < int i > class X{}, can be instanti-
ated only with constant expressions of that types (in example with constant expression that
evaluates to int).
30. Polymorfism
18
3 JAVA LANGUAGE
3 Java Language
1. Assume the following definitions in the Java language:
public interface I{
int counter = 0;
}
public class A implements I{
public A(){
counter++;
}
}
Which of the following statements are true?
19
3 JAVA LANGUAGE
20
3 JAVA LANGUAGE
5. Which of the following statements are false for the Java language?
(a) The multiple inheritance can be obtained by applying the simple inheritance by a number of
times;
(b) The simple inheritance can be simply obtained implementing a single interface;
(c) Only the abstract class can benefit from multiple inheritance;
(d) The language has extended inheritance which can replace multiple inheritance;
(a) The class will not compile as it has no method not being abstract;
(b) The class will compile and the method m1 cannot be overridden in subclasses;
(c) The class will not compile because of the visibility modifiers for the method m1;
(d) The class will not compile as an abstract class has to be public;
(e) Any non abstract class extending this class has to implement the two methods in the class
C.
21
3 JAVA LANGUAGE
(a) The visibility for the m1 method is in fact public because the class visibility is public;
(b) The classes in the same package may call the m1 method;
(c) Classes in the same package and the parent packages may call the m1 method;
(d) The sub-classes of C may call the m1 method;
(e) The sub-classes of C have to implement the m1 method.
22
3 JAVA LANGUAGE
(a) true;
(b) false;
(c) true or false depending on the compiler;
(d) the class won’t compile;
(e) 0.1.
23
3 JAVA LANGUAGE
(a) at the end of the main method, the set will contain two objects;
(b) at the end of the main method, the set will contain one object;
(c) the class will not compile as objects to be placed in HashSet or HashMap have to define the
hashCode method and the class A is not doing that;
(d) the behavior is unknown: there can be either one object or two objects in the set depending
on the compiler;
(e) the class A is not immutable.
(a) Both the above methods are correct implementations and they compute the same sum for
the same argument;
(b) The processList2 will not compile;
(c) The processList1 may throw a ConcurrentModificationException;
(d) The processList2 may throw a ConcurrentModificationException;
(e) Both methods make the argument empty as a side effect.
24
3 JAVA LANGUAGE
(a) In the Java language, placing the objects of the class A in a HashMap is safe as the class
implements the hashCode and equals methods and they are both based on the name attribute;
(b) The equals method is not correctly implemented;
(c) The class A is immutable;
(d) The equals method would be correct if an additional test on null arguments is included;
(e) The equals method called with the same argument for the same object is not guaranteed to
return the same value.
13. Which statement from the ones below are true in relation with the Java language?
14. Which statement from the ones below are true in relation with the Java language?
25
3 JAVA LANGUAGE
15. Which of the following assertions hold in relation with the Java language?
26
3 JAVA LANGUAGE
19. Which of the following statements are true in respect to the Java code below (the lines are
numbered):
1. public class Test extends Thread{
2. public void run() {
3. System.out.print(”Answer ”);
4. wait(1000);
5. System.out.print(”Question ”);
6. }
7. public static void main(String args []) {
8. Test ob = new Test();
9. ob.start();
10. }}
(a) The compilation will fail at line 4 because wait(1000) may only be called in a synchronized
block;
27
3 JAVA LANGUAGE
(b) The compilation will fail at line 4 because wait(1000) may only be called in a try/catch block
;
(c) Compilation will succeed. Nothing will be displayed on execution;
(d) Compilation will succeed. ”Answer ” will be displayed on execution;
(e) Compilation will succeed . ”Question Answer ” will be displayed on execution.
28
3 JAVA LANGUAGE
(a) 1
(b) 2
(c) 3
(d) 4
23. The Java access modifiers for the members of a class are:
24. Which of the statements below are false in respect to the Java language:
29
3 JAVA LANGUAGE
28. Which of the following statements is true about a Java abstract class:
29. Assume the file A.java includes the following Java definitions:
interface X {}
interface Y {}
public class A implements X {}
public class B extends A implements X, Y {}
Why the above code will not compile?
(a) run();
30
3 JAVA LANGUAGE
(b) a.start();
(c) new Thread(a).run();
(d) new Thread(a).start();
31
4 SOFTWARE ENGINEERING
4 Software Engineering
1. Check the statements which are true. A use case:
2. Consider the following examples of requirements for an application for a medical analyses center.
Check the functional requirements:
(a) The system must allow the management of the analysis types.
(b) The system must support maximum 20 simultaneous users.
(c) The system must allow the update of the patient record.
(d) The DES32 encription system must be used for the transfered data.
(e) The system must respond in maximum 1 second to any user command.
(f) The HELP facility must be organized hierarchically.
(g) A history of the last 20 analysis for each patient must be available.
(h) The sistem will be implemented in Java and will use DBMS Oracle.
(a) Subsistems communicate using large shared data stored in a central database.
(b) The system is composed of functional modules which process the inputs and produce outputs.
(c) The system is made of systems that provide services and systems that request these services.
(d) An event is broadcasted to all subsystems and is handled by the systems which are interested
by this event.
(e) Structures the system on more abstraction levels.
32
4 SOFTWARE ENGINEERING
33
4 SOFTWARE ENGINEERING
11. Check the circumstances that can motivate the maintenance process.
(a) The system does not pass one of the validation tests.
(b) A law, in the domain for which the application was developed, changes.
(c) Errors appear while testing the system.
(d) Errors appear while using the system.
(e) It is difficult to use the product, so it is requested to reorganize the elements in the user
interface
(f) A error is identified while performing a software inspection.
(g) Customer does not validate the user interface prototype.
(h) A component to be reused does not correspond to its specifications.
(i) Customer decides to use another database management system.
34
4 SOFTWARE ENGINEERING
13. Version management, as activity of the software configuration management process, means
(a) keeping track of requests for changes to the software, costs and impact of changes analysis
and deciding which changes should be implemented.
(b) keeping track of the multiple versions of system components and ensuring that changes made
to components by different developers do not interfere with each other.
(c) assembling program components, data and libraries, then compiling these to create an exe-
cutable system.
(d) preparing software for external release and keeping track of the system versions that have
been released for customer use.
35
4 SOFTWARE ENGINEERING
Which sequence of Java code correctly describes the relationship between classes Profesor and
Materie?
36
4 SOFTWARE ENGINEERING
Which sequence of Java code correctly and completly describes the relationship between class
Materie and class Laborator?
(a) class Materie extends Laborator\{...\}
(b) class Laborator extends Materie{...}
(c) class Materie {
private Vector <Laborator> laboratoare = new Vector();...}
class Laborator {
private Materie materie;
...}
class Laborator {
private Vector<Materie> materie;
...}
class Laborator {
private Materie materie;
...}
Check the complete and correct description of the relations represented on the diagram:
37
4 SOFTWARE ENGINEERING
(a) Association between classes Profesor and Materie; aggregation between classes Materie(aggregate)
and Test(component), Materie(aggregate) and Laborator(component), Materie(aggregate)
and Curs(component).
(b) Unidirectional association, named preda, from class Profesor to class Materie; aggrega-
tion between classes Materie(aggregate) and Test(component), Materie(aggregate) and
Laborator(component), Materie(aggregate) and Curs(component).
(c) Unidirectional association, named preda, from class Profesor to class Materie; class Materie
is superclass for classes Test, Laborator and Curs.
(d) Unidirectional association, named preda, from class Profesor to class Materie; composition
between class Materie(composite) and class Curs(component); composition between class
Materie(composite) and class Laborator(component); composition between class Materie(composite)
and class Test(component).
(e) Unidirectional association, named preda, from class Profesor to class Materie; classes Curs,
Laborator and Test inherit from class Materie.
Check all the use cases directly implied in the realization of the functions accesible to the student:
(a) Login
(b) Manage Course
(c) Select Course
(d) Study Course
(e) View Course Data
(f) Do exercises
38
4 SOFTWARE ENGINEERING
(a) getCursuri()
(b) display(listaCursuriOferite)
(c) inscriere(student, listaCursuriSelectate)
(d) Plan(listaCursuriSelectate)
(e) addPlan(planCurent)
(f) displayMsg(OK)
39
4 SOFTWARE ENGINEERING
Check the classes from which are instantiated the objects implied in the interaction:
(a) InscriereForm
(b) ControlerInscriere
(c) listaCursuriSelectate
(d) curent
(e) Student
(f) Plan
(g) planCurent
40
4 SOFTWARE ENGINEERING
24. Check the statements that comply with the rules for building robustness diagrams:
41
4 SOFTWARE ENGINEERING
(h) Return to the state Asteptare after the occurrence of event calibrare() is realized by
passing through states Calibrare, Testare and Transmitere.
Which sequence of Java code correctly and completly defines what results from the diagram for
class Angajat?
42
4 SOFTWARE ENGINEERING
43
4 SOFTWARE ENGINEERING
29. Which sequences of Java code are valid for class Rezervare?
(a) Class Student defines an aggregate of objects of type Proiect; classes RaportTestare and
DiagrameUML define compositions of objects of type Proiect.
(b) Class Proiect defines compositions of objects of type Student, of objects of type DiagrameUML
and of objects of type RaportTestare.
(c) Class Proiect defines an aggregate of objects of type Student and compositions of objects
of type DiagrameUML and of objects of type RaportTestare.
(d) Class Proiect defines a composition of objects of type Student and aggregates of objects of
type DiagrameUML and of objects of type RaportTestare.
(e) Class Proiect has an association relationship with class CodSursa.
44
5 ANSWERS
5 Answers
C Language
45
5 ANSWERS
C++ Language
46
5 ANSWERS
Java Language
1. 1d 16. 16d
2. 2a,2d 17. 17b,17d
3. 3a,3b,3d,3e 18. 18a
4. 4b 19. 19b
5. 5a,5b,5c,5d 20. 20d
6. 6c 21. 21a,21b,21c,21d
7. 7b,7d 22. 22d
8. 8b,8c,8e 23. 23a
9. 9c 24. 24b,24d
10. 10a,10e 25. 25d
11. 11c 26. 26a,26c
12. 12b,12e 27. 27a,27c
13. 13a,13c,13e 28. 28a,28c
14. 14a,14c,14d 29. 29c
15. 15b,15c 30. 30d
47
5 ANSWERS
Software Engineering
48