Imagem de fundo

Para produzir a interface gráfica ilustrada acima, a linha...

Código I – para os itens de 51 a 63


01 public class Estrutura {

02___private class No {

03_____int valor: int qtd; No filhoE, filhoD;

04_____No(int valor) {this.valor = valor; qtd = 1;}

05_____No insere(int valor) {

06_______if (this.valor > valor) {

07_________if (filhoE == null) ( filhoE = new NHo(valor); return filhoE;

08__________} else ( return filhoE.insere(valor);

09__________}

10________} else if (this.valor < valor) {

11__________if (filhoD == null) ( filhoD = new Ho(valor); return filhoD;

12__________} else { return filhoD.insere(valor);

13_________}

14________} else {

15__________qtd++; return this;

16________}

17_____}

18_____void atravessa() {

19________if (filhoD != null) filhoD.atravessa();

20________System.out.print("("+valor+","+gtd+")");

21________if (filhoE != null) filhoE.atravessa();

22_____}

23___}

24___String nome; No raiz;

25___Estrutura(String nome) (this.nome = nome;raiz = null;)

26___No insere(int valor) {

27_____if (raiz == null) (raiz = new No(valor) ;return raiz;

28_____} else return raiz.insere(valor);

29___}

30___void atravessa() {

31_____if (raiz == null) return;

32_____System.out .print(nome+"={") ;raiz.atravessa() ;System.out.print("}");

33___}

34___public static void main(String[] args) {

35_____Estrutura e = new Estrutura(args[0]);

36_____for (int i = 1; i < args.length; i++) {

37_______e.insere(Integer.parseInt(args[i]));

38_____}

39_____e.atravessa();

40___}

41 }


Código II – para os itens de 60 a 63


01 import java.avt.*;

02 import java.avt.event.*;

03 import javax.swing.*;

04 public class Editor implements ActionListener {

05 ___JFrame frame = new JFrame("Editor de Estrutura");

06 ___JPanel painelTopo = new JPanel();

07 ___JLabel labelvalor = new JLabel(*Valor");

08 ___JTextField textFieldValor = new JTextField("");

09 ___JButton hotaoInsere = new JButton("Insere");

10 ___JButton hotaoAtravessa = new JButton("Atravessa");

11 __JTextArea saída = new JTextArea("");

12 ___Estrutura estrutura = nev Estrutura("Editor");

13 ___Editor() {

14 _____frame. setLayout (new BorderLayout());

15 _____painelTopo.setLayout(new GridLayout(2, 2));

16 _____frame. add(painelTopo, BorderLayout.NORTH) ;

17 _____frame.add(saíida, BorderLayout.CENTER);

18 _____painelTopo.add(labelValor);

19 _____painelTopo.add(textFieldValor);

20 _____painelTopo.add(botaoInsere) ;

21 _____painelTopo. add(hotaoAtravessa) ;

22 _____hotaoInsere.addActionListener(this):

23 _____hotaoAtravessa. addActionListener(this);

24 _____frame.pack() ; frame.setVisible(true);

25 ___}

26 ___public void actionPerformed(ActionEvent argo) {

27 _____if (argo.getSource() == hbotaoInsere) {

28 _______estrutura. insere(Integer .parseInt(textFieldValor.getText())):

29 ___} else {

30 _____saida.setText (estrutura.atravessa()) ;

31 ___}

32 _}

33 _public static void main(String[] args) {

34 ___new Editor();

35 _}

36 }


O programa Java representado pelo código II acima implementa uma interface gráfica com o usuário, e utiliza as funções providas pela classe Estrutura, apresentadas no código I. Considere que, a partir da execução do programa acima, seguida da interação com o usuário, tenha sido produzido como resultado a interface gráfica apresentada na figura abaixo.


Imagem associada para resolução da questão


A partir da análise do programa acima e da saída de dados por ele produzida, julgue os itens que se seguem.

Para produzir a interface gráfica ilustrada acima, a linha 30 do código II foi executada pelo menos uma vez, sem produzir erros ou exceções, mas não há como determinar, com as informações apresentadas, se o botão Imagem associada para resolução da questão foi acionado mais de uma vez.


C

Certo


E

Errado