Sunteți pe pagina 1din 52

Tehnici de proiectare software

MULTIPLE CHOICE

1. Ce sablon de proiectare reprezinta diagrama urmatoare:

a. Abstract Factory c. Builder


b. Singleton d. Prototype
2. Ce sablon de proiectare reprezinta diagrama urmatoare:

a. FactoryMethod c. Builder
b. Singleton d. Prototype

1
3. Ce sablon de proiectare reprezinta diagrama urmatoare:

a. Singleton c. Builder
b. FactoryMethod d. Prototype
4. Ce sablon de proiectare reprezinta diagrama urmatoare:

a. Builder c. Singleton
b. FactoryMethod d. Prototype
5. Ce sablon de proiectare reprezinta diagrama urmatoare:

a. Prototype c. Singleton
b. FactoryMethod d. Builder

2
6. Ce sablon de proiectare reprezinta diagrama urmatoare:

a. Adapter c. Composite
b. Bridge d. Decorator
7. Ce sablon de proiectare reprezinta diagrama urmatoare:

a. Bridge c. Composite
b. Adapter d. Decorator

3
8. Ce sablon de proiectare reprezinta diagrama urmatoare:

a. Composite c. Bridge
b. Adapter d. Decorator
9. Ce sablon de proiectare reprezinta diagrama urmatoare:

a. Decorator c. Bridge
b. Adapter d. Composite

4
10. Ce sablon de proiectare reprezinta diagrama urmatoare:

a. Proxy c. Bridge
b. Adapter d. Composite
11. Ce sablon de proiectare reprezinta diagrama urmatoare:

a. Observer c. State
b. Visitor d. Mediator

5
12. Ce sablon de proiectare reprezinta diagrama urmatoare:

a. Iterator c. Visitor
b. Observer d. Model View Controller
13. Ce sablon de proiectare reprezinta diagrama urmatoare:

a. Chain of Responsability c. Observer


b. Visitor d. State

6
14. Ce sablon de proiectare reprezinta diagrama urmatoare:

a. Template Method c. Visitor


b. Observer d. State
15. Ce sablon de proiectare reprezinta diagrama urmatoare:

a. Reactor c. Visitor
b. Observer d. MVC

7
16. Fie urmatorul program Java:
import java.awt.*;
import java.awt.event.*;
class Model{
private int x=0;
public Model(){};
public void actiune(){x++;System.out.println(x);};
}
public class View extends Frame{
private Button b;
private Model m;
private Controller c;
public static void main(String args[]){
Frame f= new View();
}
public View(){
setTitle("Exemplu Model-View-Controller");

b= new Button("Actiune");
add(b);

m=new Model();

c=new Controller(m);
b.addActionListener(c);

setSize(100,50);
setVisible(true);
}
}

class Controller implements ActionListener{


private Model md;
public Controller(Model p){
md=p;
}
public void actionPerformed(ActionEvent e){
md.actiune();
}
}

Care afirmatie este adevarata:


a. La apasarea butonului Actiune, valoarea lui x creste cu o unitate
b. La apasarea butonului Actiune, nu se intampla nimic
c. La apasarea butonului Actiune, programul se termina
d. La apasarea butonului Actiune, fereastra se inchide

8
17. Fie urmatorul program Java:
import java.awt.*;
import java.awt.event.*;
class Model{
private int x=0;
public Model(){};
public void actiune(){x++;System.out.println(x);};
}
public class View extends Frame{
private Button b;
private Model m;
private Controller c;
public static void main(String args[]){
Frame f= new View();
}
public View(){
setTitle("Exemplu Model-View-Controller");

b= new Button("Actiune");
add(b);

m=new Model();

c=new Controller(m);
b.addActionListener(c);

setSize(100,50);
setVisible(true);
}
}

class Controller implements ActionListener{


private Model md;
public Controller(Model p){
md=p;
}
public void actionPerformed(ActionEvent e){
md.actiune();
}
}

Care afirmatie este adevarata:


a. Programul este proiectat conform sablonului Model View Controller
b. Programul este proiectat conform sablonului Observer
c. La apasarea butonului Actiune, programul se termina
d. La apasarea butonului Actiune, fereastra se inchide

9
18. Fie urmatorul program Java:
import java.awt.*;
import java.awt.event.*;
class Model{
private int x=0;
public Model(){};
public void actiune(){x++;System.out.println(x);};
}
public class View extends Frame{
private Button b;
private Model m;
private Controller c;
public static void main(String args[]){
Frame f= new View();
}
public View(){
setTitle("Exemplu Model-View-Controller");

b= new Button("Actiune");
add(b);

m=new Model();

c=new Controller(m);
b.addActionListener(c);

setSize(100,50);
setVisible(true);
}
}

class Controller implements ActionListener{


private Model md;
public Controller(Model p){
md=p;
}
public void actionPerformed(ActionEvent e){
md.actiune();
}
}

Care afirmatie este adevarata:


a. Metoda public void actionPerformed(ActionEvent e) face parte din interfata
WindowListener
b. Metoda public void actionPerformed(ActionEvent e) face parte din interfata
ActionListener
c. Programul este proiectat conform sablonului Observer
d. La apasarea butonului Actiune, programul se termina

10
19. Fie urmatorul program Java:
import java.awt.*;
import java.awt.event.*;
class Model{
private int x=0;
public Model(){};
public void actiune(){x++;System.out.println(x);};
}
public class View extends Frame{
private Button b;
private Model m;
private Controller c;
public static void main(String args[]){
Frame f= new View();
}
public View(){
setTitle("Exemplu Model-View-Controller");

b= new Button("Actiune");
add(b);

m=new Model();

c=new Controller(m);
b.addActionListener(c);

setSize(100,50);
setVisible(true);
}
}

class Controller implements ActionListener{


private Model md;
public Controller(Model p){
md=p;
}
public void actionPerformed(ActionEvent e){
md.actiune();
}
}

Care afirmatie este adevarata:


a. Metoda public void actionPerformed(ActionEvent e) face parte din interfata
WindowListener
b. Evenimentul „click” pe butonul Actiune provoaca activarea metodei
actionPerformed datorita instructiunii b.addActionListener(c);
c. Evenimentul „click” pe butonul Actiune provoaca activarea metodei
actionPerformed datorita instructiunii setVisible(true);
d. Evenimentul „click” pe butonul Actiune provoaca activarea metodei
actionPerformed datorita instructiunii setSize(100,50);

11
20. Fie urmatoarea diagrama de clase

Care afirmatie este adevarata:


a. Diagrama este conforma cu sablonul Model View Controller
b. Diagrama este conforma cu sablonul Observer
c. Diagrama este conforma cu sablonul Bridge
d. Diagrama este conforma cu sablonul Singleton

12
21. Fie urmatoarea diagrama de clase

Care afirmatie este adevarata:


a. Implementrea metodei void actionPerformed (ActionEvent) nu este obligatorie
b. Implementrea metodei void actionPerformed (ActionEvent) este obligatorie in
clasa View
c. Implementrea metodei void actionPerformed (ActionEvent) este obligatorie in
clasa Model
d. Implementrea metodei void actionPerformed (ActionEvent) este obligatorie in
clasa Controller

13
22. Fie urmatoarea diagrama de clase

Care afirmatie este adevarata:


a. Clasa View implementeaza interfata ActionListener
b. Clasa Controller implementeaza interfata WindowListener
c. Clasa ActionListener implementeaza interfata Controller
d. Clasa Controller implementeaza interfata ActionListener

14
23. Fie urmatoarea diagrama de clase

Care afirmatie este adevarata:


a. Clasa Model implementeaza interfata ActionListener
b. Clasa View implementeaza interfata ActionListener
c. Clasa ActionListener implementeaza interfata Controller
d. Clasa Controller implementeaza interfata WindowListener

15
24. Fie urmatorul program Java:
import java.awt.*;
import java.awt.event.*;
class Model{
private int x=0;
public Model(){};
public void increment(){x++;}
public void decrement(){x--;}
public int get_x(){return x;}
}
public class View extends Frame implements WindowListener{
protected Button binc;
protected Button bdec;
protected Model m;
private Controller c;
protected TextField tf;
public static void main(String args[]){
Frame f= new View();
}
public View(){
setTitle("Exemplu Model-View-Controller");

binc= new Button("MINUS");


add("North",binc);

bdec= new Button("PLUS");


add("South",bdec);

m=new Model();

c=new Controller(this);
binc.addActionListener(c);
bdec.addActionListener(c);

tf=new TextField(10);
add("Center",tf);
addWindowListener(this);
setSize(100,250);
setVisible(true);
}
public void windowClosed(WindowEvent e){}
public void windowOpened(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowActivated(WindowEvent e){}
public void windowDeactivated(WindowEvent e){}
public void windowClosing(WindowEvent e){
System.exit(0);
}

16
}

class Controller implements ActionListener{


private View vw;
public Controller(View v){
vw=v;
}
public void actionPerformed(ActionEvent e){
Button source=(Button)e.getSource();
if (source==vw.binc) vw.m.increment();
else if(source==vw.bdec) vw.m.decrement();
vw.tf.setText(String.valueOf(vw.m.get_x()));
}
}

Care afirmatie este adevarata:


a. La apasarea butonului PLUS, valoarea lui x descreste cu o unitate
b. La apasarea butonului MINUS, valoarea lui x descreste cu o unitate
c. La apasarea butonului PLUS, programul se termina
d. La apasarea butonului MINUS, fereastra se inchide

17
25. Fie urmatorul program Java:
import java.awt.*;
import java.awt.event.*;
class Model{
private int x=0;
public Model(){};
public void increment(){x++;}
public void decrement(){x--;}
public int get_x(){return x;}
}
public class View extends Frame implements WindowListener{
protected Button binc;
protected Button bdec;
protected Model m;
private Controller c;
protected TextField tf;
public static void main(String args[]){
Frame f= new View();
}
public View(){
setTitle("Exemplu Model-View-Controller");

binc= new Button("MINUS");


add("North",binc);

bdec= new Button("PLUS");


add("South",bdec);

m=new Model();

c=new Controller(this);
binc.addActionListener(c);
bdec.addActionListener(c);

tf=new TextField(10);
add("Center",tf);
addWindowListener(this);
setSize(100,250);
setVisible(true);
}
public void windowClosed(WindowEvent e){}
public void windowOpened(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowActivated(WindowEvent e){}
public void windowDeactivated(WindowEvent e){}
public void windowClosing(WindowEvent e){
System.exit(0);
}

18
}

class Controller implements ActionListener{


private View vw;
public Controller(View v){
vw=v;
}
public void actionPerformed(ActionEvent e){
Button source=(Button)e.getSource();
if (source==vw.binc) vw.m.increment();
else if(source==vw.bdec) vw.m.decrement();
vw.tf.setText(String.valueOf(vw.m.get_x()));
}
}

Care afirmatie este adevarata:


a. La apasarea butonului PLUS, valoarea lui x creste cu o unitate
b. La apasarea butonului MINUS, valoarea lui x creste cu o unitate
c. La apasarea butonului PLUS, programul se termina
d. La apasarea butonului MINUS, valoarea lui x descreste cu o unitate

19
26. Fie urmatorul program Java:
import java.awt.*;
import java.awt.event.*;
class Model{
private int x=0;
public Model(){};
public void increment(){x++;}
public void decrement(){x--;}
public int get_x(){return x;}
}
public class View extends Frame implements WindowListener{
protected Button binc;
protected Button bdec;
protected Model m;
private Controller c;
protected TextField tf;
public static void main(String args[]){
Frame f= new View();
}
public View(){
setTitle("Exemplu Model-View-Controller");

binc= new Button("MINUS");


add("North",binc);

bdec= new Button("PLUS");


add("South",bdec);

m=new Model();

c=new Controller(this);
binc.addActionListener(c);
bdec.addActionListener(c);

tf=new TextField(10);
add("Center",tf);
addWindowListener(this);
setSize(100,250);
setVisible(true);
}
public void windowClosed(WindowEvent e){}
public void windowOpened(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowActivated(WindowEvent e){}
public void windowDeactivated(WindowEvent e){}
public void windowClosing(WindowEvent e){
System.exit(0);
}

20
}

class Controller implements ActionListener{


private View vw;
public Controller(View v){
vw=v;
}
public void actionPerformed(ActionEvent e){
Button source=(Button)e.getSource();
if (source==vw.binc) vw.m.increment();
else if(source==vw.bdec) vw.m.decrement();
vw.tf.setText(String.valueOf(vw.m.get_x()));
}
}

Care afirmatie este adevarata:


a. Clasa Controller implementeaza interfata ActionListener
b. Clasa Controller implementeaza interfata WindowListener
c. Clasa View implementeaza interfata ActionListener
d. Clasa Model implementeaza interfata ActionListener

21
27. Fie urmatorul program Java:
import java.awt.*;
import java.awt.event.*;
class Model{
private int x=0;
public Model(){};
public void increment(){x++;}
public void decrement(){x--;}
public int get_x(){return x;}
}
public class View extends Frame implements WindowListener{
protected Button binc;
protected Button bdec;
protected Model m;
private Controller c;
protected TextField tf;
public static void main(String args[]){
Frame f= new View();
}
public View(){
setTitle("Exemplu Model-View-Controller");

binc= new Button("MINUS");


add("North",binc);

bdec= new Button("PLUS");


add("South",bdec);

m=new Model();

c=new Controller(this);
binc.addActionListener(c);
bdec.addActionListener(c);

tf=new TextField(10);
add("Center",tf);
addWindowListener(this);
setSize(100,250);
setVisible(true);
}
public void windowClosed(WindowEvent e){}
public void windowOpened(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowActivated(WindowEvent e){}
public void windowDeactivated(WindowEvent e){}
public void windowClosing(WindowEvent e){
System.exit(0);
}

22
}

class Controller implements ActionListener{


private View vw;
public Controller(View v){
vw=v;
}
public void actionPerformed(ActionEvent e){
Button source=(Button)e.getSource();
if (source==vw.binc) vw.m.increment();
else if(source==vw.bdec) vw.m.decrement();
vw.tf.setText(String.valueOf(vw.m.get_x()));
}
}

Care afirmatie este adevarata:


a. Clasa Controller implementeaza interfata WindowListener
b. Clasa Controller implementeaza interfata WindowListener
c. Clasa View implementeaza interfata WindowListener
d. Clasa Model implementeaza interfata ActionListener

23
28. Fie urmatorul program Java:
import java.awt.*;
import java.awt.event.*;
class Model{
private int x=0;
public Model(){};
public void increment(){x++;}
public void decrement(){x--;}
public int get_x(){return x;}
}
public class View extends Frame implements WindowListener{
protected Button binc;
protected Button bdec;
protected Model m;
private Controller c;
protected TextField tf;
public static void main(String args[]){
Frame f= new View();
}
public View(){
setTitle("Exemplu Model-View-Controller");

binc= new Button("MINUS");


add("North",binc);

bdec= new Button("PLUS");


add("South",bdec);

m=new Model();

c=new Controller(this);
binc.addActionListener(c);
bdec.addActionListener(c);

tf=new TextField(10);
add("Center",tf);
addWindowListener(this);
setSize(100,250);
setVisible(true);
}
public void windowClosed(WindowEvent e){}
public void windowOpened(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowActivated(WindowEvent e){}
public void windowDeactivated(WindowEvent e){}
public void windowClosing(WindowEvent e){
System.exit(0);
}

24
}

class Controller implements ActionListener{


private View vw;
public Controller(View v){
vw=v;
}
public void actionPerformed(ActionEvent e){
Button source=(Button)e.getSource();
if (source==vw.binc) vw.m.increment();
else if(source==vw.bdec) vw.m.decrement();
vw.tf.setText(String.valueOf(vw.m.get_x()));
}
}

Care afirmatie este adevarata:


a. Fara instructiunea binc.addActionListener(c), butoanele PLUS si MINUS
devine inactive
b. Fara instructiunea binc.addActionListener(c), butonul PLUS devine inactiv;
c. Fara instructiunea binc.addActionListener(c), butonul MINUS devine inactiv;
d. Fara instructiunea binc.addActionListener(c), butonul PLUS nu mai este
desenat in cadrul ferestyrei

25
29. Fie urmatorul program Java:
import java.awt.*;
import java.awt.event.*;
class Model{
private int x=0;
public Model(){};
public void increment(){x++;}
public void decrement(){x--;}
public int get_x(){return x;}
}
public class View extends Frame implements WindowListener{
protected Button binc;
protected Button bdec;
protected Model m;
private Controller c;
protected TextField tf;
public static void main(String args[]){
Frame f= new View();
}
public View(){
setTitle("Exemplu Model-View-Controller");

binc= new Button("MINUS");


add("North",binc);

bdec= new Button("PLUS");


add("South",bdec);

m=new Model();

c=new Controller(this);
binc.addActionListener(c);
bdec.addActionListener(c);

tf=new TextField(10);
add("Center",tf);
addWindowListener(this);
setSize(100,250);
setVisible(true);
}
public void windowClosed(WindowEvent e){}
public void windowOpened(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowActivated(WindowEvent e){}
public void windowDeactivated(WindowEvent e){}
public void windowClosing(WindowEvent e){
System.exit(0);
}

26
}

class Controller implements ActionListener{


private View vw;
public Controller(View v){
vw=v;
}
public void actionPerformed(ActionEvent e){
Button source=(Button)e.getSource();
if (source==vw.binc) vw.m.increment();
else if(source==vw.bdec) vw.m.decrement();
vw.tf.setText(String.valueOf(vw.m.get_x()));
}
}

Care afirmatie este adevarata:


a. Fara instructiunea binc.addActionListener(c), butoanele PLUS si MINUS
devine inactive
b. Fara instructiunea bdec.addActionListener(c), butonul PLUS devine inactiv;
c. Fara instructiunea binc.addActionListener(c), butonul PLUS devine inactiv;
d. Fara instructiunea binc.addActionListener(c), butonul PLUS nu mai este
desenat in cadrul ferestyrei

27
30. Fie urmatorul program Java:
import java.awt.*;
import java.awt.event.*;
class Model{
private int x=0;
public Model(){};
public void increment(){x++;}
public void decrement(){x--;}
public int get_x(){return x;}
}
public class View extends Frame implements WindowListener{
protected Button binc;
protected Button bdec;
protected Model m;
private Controller c;
protected TextField tf;
public static void main(String args[]){
Frame f= new View();
}
public View(){
setTitle("Exemplu Model-View-Controller");

binc= new Button("MINUS");


add("North",binc);

bdec= new Button("PLUS");


add("South",bdec);

m=new Model();

c=new Controller(this);
binc.addActionListener(c);
bdec.addActionListener(c);

tf=new TextField(10);
add("Center",tf);
addWindowListener(this);
setSize(100,250);
setVisible(true);
}
public void windowClosed(WindowEvent e){}
public void windowOpened(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowActivated(WindowEvent e){}
public void windowDeactivated(WindowEvent e){}
public void windowClosing(WindowEvent e){
System.exit(0);
}

28
}

class Controller implements ActionListener{


private View vw;
public Controller(View v){
vw=v;
}
public void actionPerformed(ActionEvent e){
Button source=(Button)e.getSource();
if (source==vw.binc) vw.m.increment();
else if(source==vw.bdec) vw.m.decrement();
vw.tf.setText(String.valueOf(vw.m.get_x()));
}
}

Care afirmatie este adevarata:


a. Fara instructiunea bdec.addActionListener(c), butoanele PLUS si MINUS
devine inactive
b. Fara instructiunea bdec.addActionListener(c), butonul PLUS devine inactiv;
c. Fara instructiunea binc.addActionListener(c), butonul PLUS devine inactiv;
d. Fara instructiunea binc.addActionListener(c), butonul PLUS nu mai este
desenat in cadrul ferestrei

29
31. Fie urmatorul program:
import java.util.*;
class Oscilator extends Thread {
long secunda=0;
public void run(){
while(true){
try {sleep (1000);} catch (Exception e){}
secunda++;
}
}
public long getSecunda(){return secunda;}

class MecanismCronometru extends Observable{


Oscilator osc=new Oscilator();
long timp= -1;
MecanismCronometru(){osc.start();}
void porneste(){
long timpNou;
while(true){
timpNou=osc.getSecunda();
if(timpNou!= timp){
timp=timpNou;
setChanged();
notifyObservers();
}
}
}
}

class Cadran implements Observer{


Afisare af;
public Cadran(Afisare loc){af=loc;}
public void update(Observable o, Object arg){
long secundaCurenta=((MecanismCronometru)o).timp;
if(secundaCurenta%5==0) af.afiseaza(secundaCurenta);

}
}

interface Afisare{
public void afiseaza(long i);
}

class AfisarePeMonitor implements Afisare{


public void afiseaza(long i){
System.out.println(""+i);
}
}

30
public class Cronometru{
MecanismCronometru m;
Cadran c1;
public Cronometru(){
m=new MecanismCronometru();
c1= new Cadran(new AfisarePeMonitor());
m.addObserver(c1);
m.porneste();
}
public static void main(String[] args){
Cronometru pobeda=new Cronometru();

}
}

Care afirmatie este adevarata:


a. Programul implementeaza sablonul Bridge
b. Programul implementeaza sablonul Observer
c. Programul implementeaza sablonul MVC
d. Programul implementeaza sablonul State

31
32. Fie urmatorul program Java :
import java.util.Observer;
import java.util.Observable;
import java.awt.*;
import java.awt.event.*;
public class Observator extends Frame
implements WindowListener, Observer{
static protected ModelObservabil m=new ModelObservabil();
protected Button exitB, actB;
protected TextField field;
private ButtonController buttonC;
public static void main(String args[]){
Frame fn=new Observator(0);// nu observa pe m

Frame f01=new Observator(1);// observa pe m


Frame f02=new Observator(1);// observa pe m
}

public Observator(int i){


if (i==1)m.addObserver(this);
Panel p= new Panel();
buttonC=new ButtonController(this);
exitB= new Button("Exit");
exitB.addActionListener(buttonC);
actB= new Button("modifica");
actB.addActionListener(buttonC);
field= new TextField("MyTextField");
field.setEditable(true);
p.add(exitB);
p.add(actB);
add(field);
add("North",p);
addWindowListener(this);
setSize(160,110);
setVisible(true);

}
public void windowClosed(WindowEvent e){}
public void windowOpened(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public void windowActivated(WindowEvent e){}
public void windowDeactivated(WindowEvent e){}
public void windowClosing(WindowEvent e){dispose();
//System.exit(0);
}

public void update(Observable observ, Object ob){


field.setText(m.afis);

class ButtonController implements ActionListener{


Observator view;
public ButtonController(Observator win){
view=win;
}
public void actionPerformed (ActionEvent e){
Object source=e.getSource();
if (source == view.exitB) System.exit(0);
else {
view.m.modifica();
};

32
}

class ModelObservabil extends Observable{


protected int i=0;
protected String afis=" ";
public ModelObservabil(){

setChanged();
notifyObservers();
}
public void modifica(){
i++;
afis= " "+ i;
setChanged();
notifyObservers();
}
}

Care afirmatie este adevarata:


a. Valoarea lui m.i se modifica prin actionarea butonului „modifica” din oricare dintre
ferestrele fn, fo1,fo2.
b. Valoarea lui m.i se modifica numaiu prin actionarea butonului „modifica” din
fereastra fn
c. Valoarea lui m.i se modifica numaiu prin actionarea butonului „modifica” din
fereastra fo1
d. Valoarea lui m.i se modifica numaiu prin actionarea butonului „modifica” din
fereastra fo2

33
33. Fie urmatorul program Java :
import java.util.Observer;
import java.util.Observable;
import java.awt.*;
import java.awt.event.*;
public class Observator extends Frame
implements WindowListener, Observer{
static protected ModelObservabil m=new ModelObservabil();
protected Button exitB, actB;
protected TextField field;
private ButtonController buttonC;
public static void main(String args[]){
Frame fn=new Observator(0);// nu observa pe m

Frame f01=new Observator(1);// observa pe m


Frame f02=new Observator(1);// observa pe m
}

public Observator(int i){


if (i==1)m.addObserver(this);
Panel p= new Panel();
buttonC=new ButtonController(this);
exitB= new Button("Exit");
exitB.addActionListener(buttonC);
actB= new Button("modifica");
actB.addActionListener(buttonC);
field= new TextField("MyTextField");
field.setEditable(true);
p.add(exitB);
p.add(actB);
add(field);
add("North",p);
addWindowListener(this);
setSize(160,110);
setVisible(true);

}
public void windowClosed(WindowEvent e){}
public void windowOpened(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public void windowActivated(WindowEvent e){}
public void windowDeactivated(WindowEvent e){}
public void windowClosing(WindowEvent e){dispose();
//System.exit(0);
}

public void update(Observable observ, Object ob){


field.setText(m.afis);

class ButtonController implements ActionListener{


Observator view;
public ButtonController(Observator win){
view=win;
}
public void actionPerformed (ActionEvent e){
Object source=e.getSource();
if (source == view.exitB) System.exit(0);
else {
view.m.modifica();
};

34
}

class ModelObservabil extends Observable{


protected int i=0;
protected String afis=" ";
public ModelObservabil(){

setChanged();
notifyObservers();
}
public void modifica(){
i++;
afis= " "+ i;
setChanged();
notifyObservers();
}
}

Care afirmatie este adevarata:


a. Programul implementeaza sabloanele Model View Controller si Observer
b. Programul implementeaza doar sablonul Model View Controller
c. Programul implementeaza doar sablonul Observer
d. Programul implementeaza sablonul Bridge

35
34. Fie urmatorul program Java :
import java.util.Observer;
import java.util.Observable;
import java.awt.*;
import java.awt.event.*;
public class Observator extends Frame
implements WindowListener, Observer{
static protected ModelObservabil m=new ModelObservabil();
protected Button exitB, actB;
protected TextField field;
private ButtonController buttonC;
public static void main(String args[]){
Frame fn=new Observator(0);// nu observa pe m

Frame f01=new Observator(1);// observa pe m


Frame f02=new Observator(1);// observa pe m
}

public Observator(int i){


if (i==1)m.addObserver(this);
Panel p= new Panel();
buttonC=new ButtonController(this);
exitB= new Button("Exit");
exitB.addActionListener(buttonC);
actB= new Button("modifica");
actB.addActionListener(buttonC);
field= new TextField("MyTextField");
field.setEditable(true);
p.add(exitB);
p.add(actB);
add(field);
add("North",p);
addWindowListener(this);
setSize(160,110);
setVisible(true);

}
public void windowClosed(WindowEvent e){}
public void windowOpened(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public void windowActivated(WindowEvent e){}
public void windowDeactivated(WindowEvent e){}
public void windowClosing(WindowEvent e){dispose();
//System.exit(0);
}

public void update(Observable observ, Object ob){


field.setText(m.afis);

class ButtonController implements ActionListener{


Observator view;
public ButtonController(Observator win){
view=win;
}
public void actionPerformed (ActionEvent e){
Object source=e.getSource();
if (source == view.exitB) System.exit(0);
else {
view.m.modifica();
};

36
}

class ModelObservabil extends Observable{


protected int i=0;
protected String afis=" ";
public ModelObservabil(){

setChanged();
notifyObservers();
}
public void modifica(){
i++;
afis= " "+ i;
setChanged();
notifyObservers();
}
}

Care afirmatie este adevarata:


a. La modificarea lui m.i, noua valoare este afisata doar in ferestrele fo1 si fo2.
b. La modificarea lui m.i, noua valoare este afisata in ferestrele fn, fo1, fo2
c. La modificarea lui m.i, noua valoare este afisata doar in fereastra fo1
d. La modificarea lui m.i, noua valoare este afisata doar in fereastra fo2

37
35. Fie urmatorul program Java :
import java.util.Observer;
import java.util.Observable;
import java.awt.*;
import java.awt.event.*;
public class Observator extends Frame
implements WindowListener, Observer{
static protected ModelObservabil m=new ModelObservabil();
protected Button exitB, actB;
protected TextField field;
private ButtonController buttonC;
public static void main(String args[]){
Frame fn=new Observator(0);// nu observa pe m

Frame f01=new Observator(1);// observa pe m


Frame f02=new Observator(1);// observa pe m
}

public Observator(int i){


if (i==1)m.addObserver(this);
Panel p= new Panel();
buttonC=new ButtonController(this);
exitB= new Button("Exit");
exitB.addActionListener(buttonC);
actB= new Button("modifica");
actB.addActionListener(buttonC);
field= new TextField("MyTextField");
field.setEditable(true);
p.add(exitB);
p.add(actB);
add(field);
add("North",p);
addWindowListener(this);
setSize(160,110);
setVisible(true);

}
public void windowClosed(WindowEvent e){}
public void windowOpened(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public void windowActivated(WindowEvent e){}
public void windowDeactivated(WindowEvent e){}
public void windowClosing(WindowEvent e){dispose();
//System.exit(0);
}

public void update(Observable observ, Object ob){


field.setText(m.afis);

class ButtonController implements ActionListener{


Observator view;
public ButtonController(Observator win){
view=win;
}
public void actionPerformed (ActionEvent e){
Object source=e.getSource();
if (source == view.exitB) System.exit(0);
else {
view.m.modifica();
};

38
}

class ModelObservabil extends Observable{


protected int i=0;
protected String afis=" ";
public ModelObservabil(){

setChanged();
notifyObservers();
}
public void modifica(){
i++;
afis= " "+ i;
setChanged();
notifyObservers();
}
}

Care afirmatie este adevarata:


a. Obiectele fo1 si fo2 sunt obiecte care observa obiectul m.
b. Doar fn observa pe m
c. Doar fo1 observa pe m
d. Doar fo2 observa pe m

39
36. Fie urmatoarea diagrama de colaborare intre obiecte.

Care din urmatoarele afirmatii este adevarata:


a. Diagrama reprezinta colaborarea intre obiectele sablonului Observer-Observable
b. Diagrama reprezinta colaborarea intre obiectele sablonului MVC
c. Diagrama reprezinta colaborarea intre obiectele sablonului Bridge
d. Diagrama reprezinta colaborarea intre obiectele sablonului State

37. Ce sablon de proiectare reprezinta diagrama urmatoare:

a. Strategy c. Observer
b. Visitor d. State

40
38. Ce sablon de proiectare reprezinta diagrama urmatoare:

a. State c. Proxy
b. Visitor d. State
39. Ce sablon de proiectare reprezinta diagrama urmatoare:

a. Bridge c. Decorator
b. Visitor d. State

41
40. Ce sablon de proiectare reprezinta diagrama urmatoare:

a. Composite c. Strategy
b. Visitor d. Bridge
41. Ce sablon de proiectare reprezinta diagrama urmatoare:

a. Flyweight c. Composite
b. Proxy d. Bridge

42
42. Ce sablon de proiectare reprezinta diagrama urmatoare:

a. Interpreter c. Observer
b. Prototype d. Iterator
43. Ce sablon de proiectare reprezinta diagrama urmatoare:

a. Decorator c. Observer
b. Prototype d. Proxy

43
44. Ce sablon de proiectare reprezinta diagrama urmatoare:

a. Chain of responsability c. Adapter


b. Prototype d. Bridge
45. Ce sablon de proiectare reprezinta diagrama urmatoare:

a. Facade c. Adapter
b. Prototype d. Decorator

44
46. Ce sablon de proiectare reprezinta diagrama urmatoare:

a. Adapter c. Proxy
b. Bridge d. Decorator
47. Ce sablon de proiectare reprezinta diagrama urmatoare:

a. Proxy c. Adapter
b. Mediator d. Decorator

45
48. Ce sablon de proiectare reprezinta diagrama urmatoare:

a. Command c. Mediator
b. Builder d. Facade
49. Ce sablon de proiectare reprezinta diagrama urmatoare:

a. Memento c. State
b. Composite d. Visitor

46
50. Ce sablon de proiectare reprezinta diagrama urmatoare:

a. Iterator c. Observer
b. Compozite d. Visitor
51. Ce sablon de proiectare reprezinta diagrama urmatoare:

a. Mediator c. Proxy
b. Adapter d. Facade

47
52. Ce sablon de proiectare reprezinta diagrama urmatoare:

a. Observer c. Proxy
b. Decorator d. Template Method
53. Ce sablon de proiectare reprezinta diagrama urmatoare:

a. Template Method c. Proxy


b. Bridge d. Decorator

48
54. Ce sablon de proiectare reprezinta diagrama urmatoare:

a. Visitor c. Observer
b. Iterator d. Interpreter

49
55. Ce sablon de proiectare reprezinta diagrama urmatoare:

a. Factory Method c. Facade


b. Bridge d. Decorator
56. Ce sablon de proiectare reprezinta diagrama urmatoare:

a. Prototype c. Facade
b. Bridge d. Decorator

50
57. Ce sablon de proiectare reprezinta diagrama urmatoare:

a. Abstract Factory c. Facade


b. Bridge d. Decorator

51
58. Ce sablon de proiectare reprezinta diagrama urmatoare:

a. Builder c. Bridge
b. Factory Method d. Decorator
59. Ce sablon de proiectare reprezinta diagrama urmatoare:

a. Singleton c. Facade
b. Bridge d. Decorator
60. Ce sablon de proiectare nu este un sablon creational ?
a. Decorator c. Prototype
b. Builder d. Abstract Factory

52