You are on page 1of 26

Anlise de Programao

Profor: Gilberto Braga de Oliveira

Nome____________________________________________ Nmero:_______ Srie____________________

Simulado 1 SCJA
Competncias: Avaliar e implementar projetos de sistemas. Habilidades: Entender a orientao a objetos na construo de sistemas; Utilizar ferramentas de apoio ao desenvolvimento de software. Bases Tecnolgicas: Metodologias de anlise de projeto de sistemas orientados a objetos. SCJA: (Sun Certified Java Associate) Certifica conceitos bsicos de orientao a objeto, linguagem de programao Java e conhecimentos gerais acerca da plataforma e das tecnologias Java.

1.

You are creating a space flight simulation for a startup aeronautics company. This simulation program must calculate the orbital mechanics and display the flight path on a graphics screen. What type of data is most appropriate for calculating the orbital mechanics equations?:
a) b) c) d) e) ( ( ( ( ( ) ) ) ) ) - pixel - boolean - integer float point enumerated type

2.

Which two are true about enumerated types in Java? (Choose two.).
a) b) c) d) ( ) An enumerated type must be a finite set of values ( ) An enumerated type is a symbol that is equivalent to an integer constant ( ) The literals of an enumerated type may be used as values to case statements in a switch statement ( ) The literals of an enumerated type must always be identifiers in all uppercase, such as ONE, TWO, and THREE ( ) An interface defines a set of methods, some of which are abstract ( ) An interface is an abstract class in which all of its methods are abstract ( ) An interface defines a set of abstract methods that may have many implementations ( ) An interface is a member of an abstract or concrete class that declares all of the public methods of the class ( ) An association may be one-to-many, but compositions are restricted to one-toone ( ) Associations permit public navigation methods, but composition prohibits such methods ( ) Composition implies that the owning object controls the life cycle of the owned object ( ) Associations merely imply that one object uses another object during computations ( ) Such a class is NOT portable across on JVM platforms ( ) Clients of such a class can set attributes to unrealistic values ( ) Such a class will NOT compile using Java without using special compiler flags ( ) Changing constraints on an attribute might require modifying code for client classes that set this attribute

3.

What is the purpose of a software interface?


a) b) c) d)

4.

What is the critical difference between class associations and class compositions?
a) b) c) d)

5.

Which two are consequences of classes that do NOT support information hiding? (Choose two.)
a) b) c) d)

Rodovia Pref. Luiz Salomo Chamma, S/N Km 41 Pouso Alegre CEP 07895-340 Franco da Rocha SP Brasil - Telefones (11) 4443-6110/4449-3115 E-mail: etefrancodarocha@hotmail.com Site: http://www.etecfran.com.br/

Anlise de Programao

Profor: Gilberto Braga de Oliveira

6.

Which two are disadvantages of proper information hiding? (Choose two.).


a) b) c) d) ( ) Access to object attributes incur a runtime penalty ( ) Object attributes are completely hidden from modification ( ) It is time consuming to use methods to access object attributes rather than direct access ( ) Without direct access to attributes in a class hierarchy, the superclass is less reusable ( ) All types in a program should be interfaces and NOT classes ( ) Good design requires every class to be an implementation of an interface ( ) References to objects should be declared as interfaces rather than concrete classes ( ) For an object to be polymorphic, it must be created from an interface rather than a class

7.

What does it mean to "program to an interface"?


a) b) c) d)

8.

Which two are true? (Choose two.)

Ilustrao 1 Classe Cliente


a) b) c) d) e) ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) The The The The The name attribute is private. Customer class is well encapsulated Customer element represents an interface Customer element represents an abstract class getName operation is public and takes a String argument

9.

Which is a correct representation of an attribute in UML?


a) b) c) d) a) b) c) d) a) b) c) d) e) - int attr - attr : int - int : attr private int attr ? 0..* 0..1 ?..1 ? * M 0..? 0..* 2

10. Which UML multiplicity indicator represents an optional association?

11. Which two UML multiplicity indicators represent zero or more? (Choose two.)

Rodovia Pref. Luiz Salomo Chamma, S/N Km 41 Pouso Alegre CEP 07895-340 Franco da Rocha SP Brasil - Telefones (11) 4443-6110/4449-3115 E-mail: etefrancodarocha@hotmail.com Site: http://www.etecfran.com.br/

Anlise de Programao f) ( ) 0..M

Profor: Gilberto Braga de Oliveira

12. Which valid Java code implements this UML class diagram?

Ilustrao 2 - Classes Cartas e Nipes


a) ( )

1. enum Suit { Spades, Hearts, Clubs, Diamonds } 2. 3. class PlayingCard { 4. Suit suit = Suit.Spades; 5. }
b) ( )

c)

1. enum Suit { Spades, Hearts, Clubs, Diamonds } 2. 3. class PlayingCard { 4. Suit suit = Spades; 5. } 1. enum Suit { SPADES, HEARTS, CLUBS, DIAMONDS } 2. 3. class PlayingCard { 4. Suit suit = SPADES; 5. }
d) ( )

1. enumeration Suit { Spades, Hearts, Clubs, Diamonds } 2. 3. class PlayingCard { 4. suit : Suit = Spades; 5. }
e) ( )

1. enumeration Suit { Spades, Hearts, Clubs, Diamonds } 2. 3. class PlayingCard { 4. suit : Suit = Suit.Spades; 5. }

Rodovia Pref. Luiz Salomo Chamma, S/N Km 41 Pouso Alegre CEP 07895-340 Franco da Rocha SP Brasil - Telefones (11) 4443-6110/4449-3115 E-mail: etefrancodarocha@hotmail.com Site: http://www.etecfran.com.br/

Anlise de Programao

Profor: Gilberto Braga de Oliveira

13. How many of the MyClass attributes will be object references when this class is implemented in the Java language?

Ilustrao 3 - Relao entre as classes MyClass e Season


a) b) c) d) e) f) g) ( ( ( ( ( ( ( ) ) ) ) ) ) ) 0 1 2 3 4 5 6

14. Which valid Java code implements this UML class diagram?

Ilustrao 4 - Classe MyClass


a) ( )

1. class MyClass { 2. - x : int; 3. - y : int; 4. + z : int; 5. - ch : char; 6. + vel : float; 7. + acc : float; 8. }
b) ( )

1. class MyClass { 2. private x : int; 3. private y : int; 4. public z : int;


Rodovia Pref. Luiz Salomo Chamma, S/N Km 41 Pouso Alegre CEP 07895-340 Franco da Rocha SP Brasil - Telefones (11) 4443-6110/4449-3115 E-mail: etefrancodarocha@hotmail.com Site: http://www.etecfran.com.br/ 4

Anlise de Programao

Profor: Gilberto Braga de Oliveira

5. private ch : char; 6. public vel : float; 7. public acc : float; 8. }


c) ( )

1. class MyClass { 2. - int x; 3. - int y; 4. + int z; 5. - char ch; 6. + float vel; 7. + float acc; 8. }
d) ( )

e)

1. class MyClass { 2. private int x; 3. private int y; 4. public int z; 5. private char ch; 6. public float vel; 7. public float acc; 8. } 1. class MyClass { 2. private: 3. int x; 4. int y; 5. char ch; 6. public: 7. int z; 8. float vel; 9. float acc; 10. }

Rodovia Pref. Luiz Salomo Chamma, S/N Km 41 Pouso Alegre CEP 07895-340 Franco da Rocha SP Brasil - Telefones (11) 4443-6110/4449-3115 E-mail: etefrancodarocha@hotmail.com Site: http://www.etecfran.com.br/

Anlise de Programao

Profor: Gilberto Braga de Oliveira

15. Which valid Java code implements this UML class diagram?

Ilustrao 5 Classes A, B e C
a) ( )

b)

1. class A { 2. void methodA() {/* initial code */ } 3. } 4. class B { 5. void methodB() {/* initial code */ } 6. } 7. class C extends A, B { 8. void methodA() { /* override code */ } 9. void methodB() { /* override code */ } 10. } 1. class A { 2. methodA() : void 3. } 4. class B { 5. methodB() : void 6. } 7. class C extends A, 8. methodA() : void 9. methodB() : void 10. }
c) ( )

{/* initial code */ } {/* initial code */ } B { { /* impl code here */ } { /* impl code here */ }

1. 2. 3. 4. 5. 6. 7. 8. 9.

interface A { void methodA(); } interface B { void methodB(); } class C implements A, B { public void methodA() { /* impl code here */ } public void methodB() { /* impl code here */ }
6

Rodovia Pref. Luiz Salomo Chamma, S/N Km 41 Pouso Alegre CEP 07895-340 Franco da Rocha SP Brasil - Telefones (11) 4443-6110/4449-3115 E-mail: etefrancodarocha@hotmail.com Site: http://www.etecfran.com.br/

Anlise de Programao

Profor: Gilberto Braga de Oliveira

10. }
d) ( )

e)

1. interface A { 2. methodA() : void; 3. } 4. interface B { 5. methodB() : void; 6. } 7. class C implements A, B { 8. methodA() : void { /* impl code here */ } 9. methodB() : void { /* impl code here */ } 10. } 1. class MyClass { 2. private: 3. int x; 4. int y; 5. char ch; 6. public: 7. int z; 8. float vel; 9. float acc; 10. }

f) g)

( ) This is NOT a valid UML diagram ( ) This is a valid UML diagram, but this model cannot be implemented using the Java programming language.

16. Which two UML multiplicity indicators represent zero or more? (Choose two.)

Ilustrao 6 Classes Customer e Address


a) ( )

1. 2. 3. 4. 5. 6.
b) ( )

class Customer { addr : Address; Customer(addr : Address) { this.addr = addr; } } class Address { } class Customer { Address addr; Customer(Address addr) { this.addr = addr; } } class Address { }

c)

1. 2. 3. 4. 5. 6.

1. class Customer { 2. addr : Address; 3. Customer(addr : Address) { this.addr = addr; } 4. getAddress() : Address { return this.addr; } 5. setAddress(addr : Address) : void { this.addr =
Rodovia Pref. Luiz Salomo Chamma, S/N Km 41 Pouso Alegre CEP 07895-340 Franco da Rocha SP Brasil - Telefones (11) 4443-6110/4449-3115 E-mail: etefrancodarocha@hotmail.com Site: http://www.etecfran.com.br/ 7

Anlise de Programao

Profor: Gilberto Braga de Oliveira

6. 7. 8. 9.
d) ( )

addr; } } class Address { } class Customer { Address addr; Customer(Address addr) { this.addr = addr; } Address getAddress() { return this.addr; } void setAddress(Address addr) { this.addr = addr; } } class Address { }

1. 2. 3. 4. 5. 6. 7. 8.
e) f)

( ) This is NOT a valid UML diagram ( ) This is a valid UML diagram, but this model cannot be implemented using the Java programming language.

17. Which valid Java code implements this UML class diagram?

Ilustrao 7 Classes Customer e Address


a) ( )

b)

1. 2. 3. 4. 5. 1. 2. 3. 4. 5.
c) ( )

class Customer { addr : Address [1..5]; } class Address { } class Customer { Address[1..5] addr; } class Address { } class Customer { Address[] addr = new Address[5]; } class Address { } class Customer { addr : Address []; } class Address { }

d)

1. 2. 3. 4. 5. 1. 2. 3. 4. 5.
e) f)

( ) This is NOT a valid UML diagram ( ) This is a valid UML diagram, but this model cannot be implemented using the Java programming language.

18. Which two object-oriented principles are being used on line 10? (Choose two.). Given:

5. interface List { /* method declarations */ }


Rodovia Pref. Luiz Salomo Chamma, S/N Km 41 Pouso Alegre CEP 07895-340 Franco da Rocha SP Brasil - Telefones (11) 4443-6110/4449-3115 E-mail: etefrancodarocha@hotmail.com Site: http://www.etecfran.com.br/ 8

Anlise de Programao

Profor: Gilberto Braga de Oliveira

6. class MyList implements List { /* method implementations */ } 7. class YourList implements List { /* method implementations */ } 8. 9. public class Client { 10. public void test(List myData) { /* test code */ } 11. }
a) b) c) d) a) b) c) d) e) ( ( ( ( ( ( ( ( ( ) ) ) ) ) ) ) ) ) Polymorphism Information hiding Multiple inheritance Program to an interface iteration assignment conditional declaration instantiation

19. Which type of Java statement must be used to calculate the equation y = ax + bx + c?

20. Which two Java statement types must be used to search for a given object in an array of objects? (Choose two).
a) b) c) d) e) ( ( ( ( ( ) ) ) ) ) iteration assignment conditional declaration instantiation

21. You must create a class that represents a quadratic formula, f(x) = ax + bx + c, in which objects store the formula's constants, a, b, and c, and the class has a single method f. Which variable scope must be used in this class to encode the formula's constants?
a) b) c) d) e) a) b) c) d) e) f) a) b) c) d) e) f) ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) local variable static variable global variable method parameter instance variable if for else endif switch else-if Object obj = 0; Object obj = null; Object obj = NULL; obj : Object = null; obj : Object = NULL; Object obj = UNKNOWN;

22. Which two keywords directly support Boolean conditional statements? (Choose two.)

23. Which statement declares a null object reference?

24. Which valid Java code declares the method for this pseudo-code? Given:

1. function sum of array of integers returns integer do: 2. sum := 0


Rodovia Pref. Luiz Salomo Chamma, S/N Km 41 Pouso Alegre CEP 07895-340 Franco da Rocha SP Brasil - Telefones (11) 4443-6110/4449-3115 E-mail: etefrancodarocha@hotmail.com Site: http://www.etecfran.com.br/ 9

Anlise de Programao

Profor: Gilberto Braga de Oliveira

3. for each x in the array 4. sum := sum + x 5. endfor 6. return sum 7. endfunction
a) b) c) d) ( ( ( ( ) ) ) )

int sum(int[] array) { /* code here */ } sum(array : int[]) : int { /* code here */ } integer sum(integer[] array) { /* code here */ } sum(array : integer[]) : integer { /* code here */ }

25. Which two expressions, taken individually, evaluate to 420? (Choose two.)

1. x=41 2. y=2 3. z=10

a) b) c) d) e)

( ( ( ( (

) ) ) ) )

x + --y * z x++ * z / y ++x * z / --y (x + --y) * z (x + y)-- * z

26. Which expression evaluates to false? Given:

1. x=41 2. y=2 3. z=10

a) b) c) d)

( ( ( (

) ) ) )

!(x !(x !(x !(x

== y) && (x == z) == y) || (x == z) == y) == (x != z) != y) || (x != z)

27. You must determine if a text field in a GUI screen has been left empty. Even if the user types in spaces, the text field is considered empty. Which line of code evaluates to true if the String variable, fieldValue, is empty by these requirements? Assume that you already know fieldValue is NOT null.
a) b) c) d) e) a) b) c) d) e) ( ( ( ( ( ( ( ( ( ( ) ) ) ) ) ) ) ) ) ) fieldValue.equals("") fieldValue.trim() == null fieldValue.trim().length() == 0 fieldValue.removeWhitespace().equals("") fieldValue.removeWhitespace().length() == 0 A A A A A source source source source source file file file file file must have exactly one package statement. can have zero package statements or one package statement can have zero package statements to many package statements automatically imports all classes of its package automatically imports all built-in Java SE classes

28. Which two are true? (Choose two.)

29. Which is the valid Java syntax for specifying that the Dimension class belongs in the java.awt package?
a) b) c) d) ( ( ( ( ) ) ) ) package java.awt; #pragma package java.awt; package java.awt.Dimension; #pragma package java.awt.Dimension;

30. What is the result of this command-line execution? Given:

1. java -version com.example.MyProgram


a) ( ) The Java interpreter executes the program 10

Rodovia Pref. Luiz Salomo Chamma, S/N Km 41 Pouso Alegre CEP 07895-340 Franco da Rocha SP Brasil - Telefones (11) 4443-6110/4449-3115 E-mail: etefrancodarocha@hotmail.com Site: http://www.etecfran.com.br/

Anlise de Programao Profor: Gilberto Braga de Oliveira b) ( ) The Java interpreter prints an error message and exits c) ( ) The Java interpreter prints the version information and exits d) ( ) The Java interpreter prints the version information and executes the program

31. Which two are true about the Collections API? (Choose two.)
a) b) c) d) a) b) c) d) ( ( ( ( ( ( ( ( ) ) ) ) ) ) ) ) The The The The Collections Collections Collections Collections APIs APIs APIs APIs contain interfaces for lists and sets are in the java.util package contain interfaces for stacks and queues are in the java.collections package

32. Which package contains APIs that are useful for distributed programming and communication?
java.awt java.net java.util javax.swing

33. You must develop a business application for sales people to use their cell phones to register client contacts to a central business server. Furthermore, the central server requires EJB technology to process the sales contact information. Which Java edition (or editions) are required to develop the application?
a) b) c) d) e) f) ( ( ( ( ( ( ) ) ) ) ) ) only J2SE only J2EE only J2ME J2SE and J2EE J2SE and J2ME J2EE and J2ME

34. You must develop a desktop-based, graphical, multi-user role-playing game that is run over the Internet but does NOT require a central server. Which Java edition (or editions) are required to develop the application?
a) b) c) d) e) f) a) b) c) d) a) b) c) d) a) b) c) d) ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) only J2SE only J2EE only J2ME J2SE and J2EE J2SE and J2ME J2EE and J2ME TCP/IP sockets are the basis of RMI. RMI may create new threads for each request Sockets create new threads for each connection Sockets use the RMI registry to open TCP/IP connections JMS SQL HTTP RDBMS SQL SQL SQL SQL can generate dynamic HTML content is used to create tables and views can read data from relational databases is Java technology's interface to relational databases

35. Which two are true about sockets and RMI? (Choose two.)

36. Which provides a standard protocol to communicate with a relational database?

37. Which two are characteristics of SQL? (Choose two.)

38. Which technology provides a standard interface for sending asynchronous messages to an enterprise server?
Rodovia Pref. Luiz Salomo Chamma, S/N Km 41 Pouso Alegre CEP 07895-340 Franco da Rocha SP Brasil - Telefones (11) 4443-6110/4449-3115 E-mail: etefrancodarocha@hotmail.com Site: http://www.etecfran.com.br/ 11

Anlise de Programao a) ( ) JMS b) ( ) SQL c) ( ) HTTP d) ( ) RDBMS

Profor: Gilberto Braga de Oliveira

39. Which is true?


a) b) c) d) ( ) HTML ( ) HTML maintain ( ) HTML ( ) HTML browsers ( ( ( ( ( ( ( ( ( ( ( ( to ( ( ( ( ( ( ( ( ( ) ) ) ) ) ) ) ) HTML HTML HTML HTML HTML HTML HTML HTML applications have rich user interface interactivity applications must be distributed manually, making them hard to applications use a Java Runtime Environment to provide interactivity applications are automatically distributed by web servers to clients'

40. Which two are disadvantages of HTML? (Choose two.)


a) b) c) d) a) b) c) d) a) b) c) d) does does does does does does does does NOT NOT NOT NOT NOT NOT NOT NOT provide provide provide provide provide provide provide provide interactive capabilities. a rich set of UI components. screen navigation capabilities. rich text formatting capabilities interactive capabilities. a rich set of UI components. screen navigation capabilities. rich text formatting capabilities

41. Which two are disadvantages of HTML? (Choose two.)

42. Which is a disadvantage of using Applets?


) The Applet might destroy files on the user's machine. ) The Applet might NOT execute without the necessary JRE version installed ) The Applet might send web browser cookie information to an Internet server ) The Applet might NOT be able to communicate with the enterprise server due the default security restrictions ) ) ) ) ) ) ) ) ) Applets Applets Applets Applets can read files on the client system cannot be used to create animated games. cannot connect to arbitrary Internet servers can access other Applets on the same web page

43. Which two are true? (Choose two.)


a) b) c) d) a) b) c) d) e)

44. Which standard J2SE technology supports the richest set of GUI components?
Swing MIDP GUI APIs JavaServer Faces Abstract Window Toolkit Standard Widget Toolkit

45. You must create a business logic component that generates reports from asynchronous requests in other parts of the system. Which technology is required to create this business component?
a) b) c) d) a) b) c) ( ( ( ( ( ( ( ) ) ) ) JSP JMS JDBC JNDI

46. Which pair of technologies are often used together to serve a single purpose?
) JNDI and JDBC ) Servlets and SQL ) JavaMail and SMTP 12

Rodovia Pref. Luiz Salomo Chamma, S/N Km 41 Pouso Alegre CEP 07895-340 Franco da Rocha SP Brasil - Telefones (11) 4443-6110/4449-3115 E-mail: etefrancodarocha@hotmail.com Site: http://www.etecfran.com.br/

Anlise de Programao d) ( ) JavaScript and EJB

Profor: Gilberto Braga de Oliveira

47. Which two are benefits of JSP technology? (Choose two.)


a) b) c) d) e) ( ) JSP technology ( ) JSP technology ( ) JSP technology ( ) JSP technology applications. ( ) JSP technology multiple EJB servers. simplifies the creation of dynamic web pages. provides client-side interactivity to web pages. simplifies the creation of business logic components. helps separate the job roles in building server-side web supports the integration of business components across

48. Which describes the role of a servlet developer?


a) b) c) d) ( ) a Java programmer who creates programs that execute on cell phones. ( ) a Java programmer who creates classes that respond to HTTP requests. ( ) a web designer who generates dynamic web pages to create user interfaces. ( ) a Java programmer who creates components that represent data in a relational database

49. You are creating the business logic for an eCommerce shopping cart. This component must record the user's purchase items that are selected over many interactions with eCommerce web site. This component will also be responsible for performing various check-out operations, such as charging the user's credit card and submitting the order to the shipping department. Which EJB technology can be used to create the shopping cart component?
a) b) c) d) e) a) b) c) d) a) b) c) d) e) ( ( ( ( ( ( ( ( ( ( ( ( ( ( ) ) ) ) ) ) ) ) ) ) ) ) ) ) JSP Servlet Message-driven bean Stateful session bean Stateless session bean They They They They J2EE J2EE J2EE J2EE J2EE are are are are used used used used to to to to represent persistent data handle asynchronous business logic events. represent client-independent business processes store client-specific data in the web container

50. What is an appropriate description of stateless session beans?

51. Which two are advantages of using J2EE? (Choose two.)


provides provides provides provides provides a simple programming model. highly scalable infrastructure declarative clustering management declarative transaction management declarative user interface construction

Rodovia Pref. Luiz Salomo Chamma, S/N Km 41 Pouso Alegre CEP 07895-340 Franco da Rocha SP Brasil - Telefones (11) 4443-6110/4449-3115 E-mail: etefrancodarocha@hotmail.com Site: http://www.etecfran.com.br/

13

Anlise de Programao

Profor: Gilberto Braga de Oliveira

Gabarito Comentado
1
Option A is incorrect because a pixel cannot be used to calculate orbital mechanics equations. Option B is incorrect because a boolean type cannot be used to calculate orbital mechanics equations. Option C is incorrect because an integer type cannot be used to calculate orbital mechanics equations. Option D is correct because floating point numbers are ideal for calculating orbital mechanics equations. Option E is incorrect because an enumerated type cannot be used to calculate orbital mechanics equations.

2
Option A is correct because by definition an enumerated type is a finite set of symbolic literals. Option B is incorrect because in Java an enumerated type is represented as first-class object. Option C is correct because enumerated type literals are allowed in case statements. See Java Language Specification, third edition, pg 377. Option D is incorrect because the literals of an enumerated type may be any valid Java identifier.

3
Option A is incorrect because an interface may NOT contain any concrete method implementations. Option B is incorrect because an interface is NOT a class of any style. Option C is correct because this is the definition of an interface. Option D is incorrect because an interface is NOT a member of a class.

4
Option A is incorrect because either type of relationship may be of any multiplicity. Option B is incorrect because compositions may also have navigation methods, but these methods must NOT pass references to the owned objects. This is usually achieved by passing back a copy of the object rather than the owned object itself. Option C is correct because this is the definition of composition. See UML v2.0 Superstructure Specification page 38. Option D is incorrect because this is the definition of dependency rather than association.

5
Rodovia Pref. Luiz Salomo Chamma, S/N Km 41 Pouso Alegre CEP 07895-340 Franco da Rocha SP Brasil - Telefones (11) 4443-6110/4449-3115 E-mail: etefrancodarocha@hotmail.com Site: http://www.etecfran.com.br/ 14

Anlise de Programao

Profor: Gilberto Braga de Oliveira

Option A is incorrect because the portability of a Java application is NOT dependent upon whether information hiding was used. Option B is correct because the class cannot protect bad assignments. For example, setting a negative value for an account balance. Option C is incorrect because classes that do NOT support information hiding are NOT treated specially in Java. Option D is correct. For example, if requirements for a bank account specify that the account balance must NOT be negative, then the programmer must scan all of the code that uses the account class and add this constraint to every line of code that changes the account balance attribute.

6
Option A is correct because a client must use methods to access hidden attributes. However, the Sun hotspot JVM usually can eliminate the added overhead by "inlining" the methods where they are called. Option B is incorrect because class attributes are NOT completely hidden as the class may support mutator methods for these attributes. Option C is correct because the syntax for calling a mutator method is longer than an assignment operation. Option D is incorrect because information hiding does NOT restrict the reusability of a superclass.

7
Option A is incorrect because interfaces are only contracts (declarations of public methods) and a program needs classes for actual behavior. Option B is incorrect because NOT every class will have behavior that requires an explicit contract (interface). Option C is correct because it is the reference variables to objects that need to be as generic as possible. This is the essence of the "program to an interface" principle. Option D is incorrect because an interface cannot be instantiated using the new operator.

8
Option A is correct because the minus symbol on the name attribute signifies private visibility. Option B is correct because the Customer class supports encapsulation by having all of its attributes be private and it provides appropriate public accessor and mutator methods. Option C is incorrect because the Customer element represents a concrete class. Option D is incorrect because the Customer element represents a concrete class. Option E is incorrect because the getName operation does NOT take any arguments, but does return a string value.

9
Option A is incorrect because the data type follows the attribute name.
Rodovia Pref. Luiz Salomo Chamma, S/N Km 41 Pouso Alegre CEP 07895-340 Franco da Rocha SP Brasil - Telefones (11) 4443-6110/4449-3115 E-mail: etefrancodarocha@hotmail.com Site: http://www.etecfran.com.br/ 15

Anlise de Programao

Profor: Gilberto Braga de Oliveira

Option B is correct as defined by the UML v2.0 specification page 122-123. Option C is incorrect because data type follows the attribute name. Option D is incorrect because private is NOT a valid visibility marker and because the data type follows the attribute name.

10
Option A is incorrect because ? is NOT a valid multiplicity indicator. Option B is incorrect because 0..* indicates zero or more multiplicity. Option C is correct because 0..1 indicates zero or one multiplicity, which is how you can represent an optional association. Option D is incorrect because ?..1 is NOT a valid multiplicity indicator.

11Option A is incorrect because ? is NOT a valid multiplicity indicator. Option B is correct because * is an abbreviation for 0..*. Option C is incorrect because M is NOT a valid multiplicity indicator. Option D is incorrect because ? is NOT a valid multiplicity indicator. Option E is correct because 0..* is exactly how to indicate zero or more. Option F is incorrect because M is NOT a valid multiplicity indicator.

12
Option A is correct because this is the proper Java code to implement this UML diagram. Option B is incorrect because the enum class name, Suit, must proceed the enum literal, Spades. Option C is incorrect because a true implementation of the UML diagram would keep the enum literals identical to the literals in the diagram. The code will not compile without the Suit. in front of the literal on line 4. Option D is incorrect because this is improper Java syntax for enumeration declarations as well as class attribute declarations. Option E is incorrect because this is improper Java syntax for enumeration declarations as well as class attribute declarations.

13
Option A is incorrect because there are four object reference variables: name, numbers, accelerationZ, and fashionSense. Option B is incorrect because there are four object reference variables: name, numbers, accelerationZ, and fashionSense. Option C is incorrect because there are four object reference variables: name, numbers, accelerationZ, and fashionSense.

Rodovia Pref. Luiz Salomo Chamma, S/N Km 41 Pouso Alegre CEP 07895-340 Franco da Rocha SP Brasil - Telefones (11) 4443-6110/4449-3115 E-mail: etefrancodarocha@hotmail.com Site: http://www.etecfran.com.br/

16

Anlise de Programao

Profor: Gilberto Braga de Oliveira

Option D is incorrect because there are four object reference variables: name, numbers, accelerationZ, and fashionSense. Option E is correct because there are four object reference variables: name, numbers, accelerationZ, and fashionSense. Option F is incorrect because there are four object reference variables: name, numbers, accelerationZ, and fashionSense. Option G is incorrect because there are four object reference variables: name, numbers, accelerationZ, and fashionSense.

14
Option A is incorrect because the structure of the attribute declarations is wrong. Java syntax does NOT match UML syntax. Option B is incorrect because the structure of the attribute declarations is wrong. Option C is incorrect because the structure of the attribute declarations is wrong. Java syntax does NOT match UML syntax. Option D is correct because this is the proper Java to implement this UML diagram. Option E is incorrect because the private and public keywords need to precede every attribute declaration. This is actually C++ syntax.

15
Option A is incorrect because the relationship between type A (and B) to type C is realization. Therefore, A and B are NOT classes but must be interfaces. Option B is incorrect because the relationship between type A (and B) to type C is realization. Therefore, A and B are NOT classes but must be interfaces. Also, Java syntax for method declarations does NOT match UML syntax. Option C is correct because types A and B are interfaces in this model and it is legal in Java to implement more than one interface. Option D is incorrect because Java syntax for method declarations does NOT match UML syntax. Option E is incorrect because multiple interface implementation is legal in UML. Option F is incorrect because this model represents multiple interface implementation, which is legal in Java.

16
Option A is incorrect because this is invalid attribute and method declaration syntax. Option B is correct because this model only defines an association (customer has one address), but no navigation has been defined. Option C is incorrect because this is invalid attribute and method declaration syntax. Option D is incorrect because the model does NOT define any navigation between customer and address. Option E is incorrect because this model represents a valid UML diagram. Option F is incorrect because this model can be implemented in the Java programming language.
Rodovia Pref. Luiz Salomo Chamma, S/N Km 41 Pouso Alegre CEP 07895-340 Franco da Rocha SP Brasil - Telefones (11) 4443-6110/4449-3115 E-mail: etefrancodarocha@hotmail.com Site: http://www.etecfran.com.br/ 17

Anlise de Programao

Profor: Gilberto Braga de Oliveira

17
Option A is incorrect because this is invalid attribute declaration syntax. Option B is incorrect because the multiplicity figures are NOT used in Java. An array size is NOT defined in the declaration. Option C is correct because a relationship with a multiplicity greater than one may use an array for the association attribute. Option D is incorrect because this is invalid attribute declaration syntax. Option E is incorrect because this model represents a valid UML diagram. Option F is incorrect because this model can be implemented in the Java programming language.

18
Option A is correct because the reference variable myData may be of any instance of a class that implements List. This is the definition of polymorphism. Option B is incorrect because no attributes are being hidden in this code. Option C is incorrect because multiple inheritance is illegal in Java. Option D is correct because the parameter to the test method is declared to an interface type rather than to a concrete class.

19
Option A is incorrect because an iteration is NOT necessary for this computation. Option B is correct because assignment is needed to assign the result of the formula to y. Option C is incorrect because a conditional statement is NOT necessary for this computation. Option D is incorrect because a declaration is NOT necessary for this computation. Option E is incorrect because instantiation is NOT a type of statement.

20
Option A is correct because an iteration must be used to loop through each element of the array. Option B is incorrect because assignment is NOT needed for this computation. Option C is correct because a conditional statement is needed to compare the given object to each object in the array. Option D is incorrect because a declaration is NOT necessary for this computation. Option E is incorrect because instantiation is NOT a type of statement.

21
Option A is incorrect because the local variable scope is too restrictive for this purpose. The formula's constants must be stored in instance variables.

Rodovia Pref. Luiz Salomo Chamma, S/N Km 41 Pouso Alegre CEP 07895-340 Franco da Rocha SP Brasil - Telefones (11) 4443-6110/4449-3115 E-mail: etefrancodarocha@hotmail.com Site: http://www.etecfran.com.br/

18

Anlise de Programao

Profor: Gilberto Braga de Oliveira

Option B is incorrect because the static variable scope is too broad for this purpose. The formula's constants must be stored in instance variables. Option C is incorrect because the Java language does NOT include the concept of a global variable that other languages, such as C or C++, do include. Option D is incorrect because the representation of the formula's constants will NOT change on each call to the f method. The formula's constants must be stored in instance variables. Option E is correct because the formula's constants must be stored in instance variables so that each call to the f method retains the values of the quadratic equation's constants.

22
Option A is correct because if and else are the only keywords used in a Boolean conditional statement. Option B is incorrect because for is used in iteration statements. Option C is correct because if and else are the only keywords used in a Boolean conditional statement. Option D is incorrect because endif is NOT a Java keyword. Option E is incorrect because the switch keyword is NOT used in Boolean conditional statements. Option F is incorrect because else-if is NOT a Java keyword.

23
Option A is incorrect because 0 does NOT represent the null reference value. Option B is correct because null is the Java token that represents the null reference value. Option C is incorrect because NULL does NOT represent the null reference value. Option D is incorrect because the variable declaration uses UML syntax. Option E is incorrect because the variable declaration uses UML syntax and NULL does NOT represent the null reference value. Option F is incorrect because UNKNOWN does NOT represent the null reference value.

24
Option A is correct because this is the valid Java method declaration syntax for this pseudo-code. Option B is incorrect because this is NOT valid Java method declaration syntax. Option C is incorrect because integer is NOT a valid Java primitive type for an integer. Option D is incorrect because this is NOT valid Java method declaration syntax.

25
Option A is incorrect because this expression is equivalent to 41 + (1 * 10), which equals 51.
Rodovia Pref. Luiz Salomo Chamma, S/N Km 41 Pouso Alegre CEP 07895-340 Franco da Rocha SP Brasil - Telefones (11) 4443-6110/4449-3115 E-mail: etefrancodarocha@hotmail.com Site: http://www.etecfran.com.br/ 19

Anlise de Programao

Profor: Gilberto Braga de Oliveira

Option B is incorrect because this expression is equivalent to 42 * 10 / 5, which equals 84. Option C is correct because this expression is equivalent to 42 * 10 * 1), which equals 420. Option D is correct because this expression is equivalent to (41 + 1) * 10, which equals 420. Option E is incorrect because the -- operator cannot be used on an expression.

26
Option A is correct because && is the "and" operator. This expression is equivalent to (not false) and false, which is false. Option B is incorrect because || is the "or" operator. This expression is equivalent to (not false) or false, which is true. Option C is incorrect because this expression is equivalent to (not false) equals true, which is true. Option D is incorrect because this expression is equivalent to (not true) or true, which is true.

27
Option A is incorrect because if the user types in spaces, then this expression will NOT be true. Option B is incorrect because the trim method never returns null. Option C is correct because the trim method will return an empty string if the user only types spaces into the field and the length method always returns zero (0) for an empty string. Option D is incorrect because there is no method called removeWhitespace. Option E is incorrect because there is no method called removeWhitespace.

28
Option A is incorrect because it is optional that source files have a package statement. A source file may have no package statement at all. Option B is correct because a source file may only have one package statement. Option C is incorrect because a source file may only have one package statement. Option D is correct because a source file in a given package has automatic access to all classes in that package. Option E is incorrect because only the java.lang package is automatically imported.

29
Option A is correct because this is the valid syntax for specifying the package of a class in the AWT package. Option B is incorrect because #pragma is NOT valid syntax in Java.
Rodovia Pref. Luiz Salomo Chamma, S/N Km 41 Pouso Alegre CEP 07895-340 Franco da Rocha SP Brasil - Telefones (11) 4443-6110/4449-3115 E-mail: etefrancodarocha@hotmail.com Site: http://www.etecfran.com.br/ 20

Anlise de Programao

Profor: Gilberto Braga de Oliveira

Option C is incorrect because the package statement must NOT include the class name. Option D is incorrect because #pragma is NOT valid syntax in Java.

30
Option A is incorrect because the -version option tells the Java interpreter to print the version information and exits without running the program. Option B is incorrect because this is a valid command-line option. Option C is correct because the -version option tells the Java interpreter to print the version information and exits without running the program. Option D is incorrect because the -version option tells the Java interpreter to print the version information and exits without running the program.

31
Option A is correct because the java.util package contains the interfaces List and Set. Option B is correct because the primary Collections interfaces and classes are contained in the java.util package. Option C is incorrect because java.util package does NOT contain interfaces for stacks. However, there is a class called Stack. Option D is incorrect because there is no package called java.collections.

32
Java SE API documentation. Option A is incorrect because the java.awt package contains GUI-related classes. Option B is correct because the classes for TCP and UDP communication are contained in the java.net package. Option C is incorrect because the java.util package contains utility classes, such as the Collections API. Option D is incorrect because the javax.swing package contains GUI-related classes.

33
Option A is incorrect because J2SE does NOT execute on cell phones. Option B is incorrect because J2EE does NOT execute on cell phones. Option C is incorrect because the central server needs J2EE to record the data from the salesman's cell phone transaction. Option D is incorrect because the cell phone side of the application requires the micro edition. Option E is incorrect because the server side of the application requires Enterprise JavaBeans, which is a J2EE API. Option F is correct because the cell phone side of the application requires the micro edition and the server side of the application requires the enterprise edition.
Rodovia Pref. Luiz Salomo Chamma, S/N Km 41 Pouso Alegre CEP 07895-340 Franco da Rocha SP Brasil - Telefones (11) 4443-6110/4449-3115 E-mail: etefrancodarocha@hotmail.com Site: http://www.etecfran.com.br/ 21

Anlise de Programao

Profor: Gilberto Braga de Oliveira

34
Option A is correct because the J2SE platform has rich GUI capabilities, as well as IP communication capabilities allowing multiple, Internet-wide applications to exchange data. Option B is incorrect because this application does NOT need advanced enterprise APIs. Option C is incorrect because J2ME is meant for small devices and does NOT have rich GUI capabilities. Option D is incorrect because this application does NOT need advanced enterprise APIs. Option E is incorrect because this application is NOT required to run on micro devices, such as cell phones. Option F is incorrect because this application is NOT required to run on micro devices, such as cell phones, and this application does NOT need advanced enterprise APIs.

35
Option A is correct because RMI uses TCP/IP as its underlying communication mechanism. Option B is correct because an RMI server is allowed to create threads for each incoming request. Option C is incorrect because the application developer is responsible for creating threads to handle socket connections. Option D is incorrect because IP addresses (not the RMI registry) are used to create TCP/IP connections.

36
Option A is incorrect because JMS is used to communicate with messaging services. Option B is correct because SQL is the standard language to communicate with a database. Option C is incorrect because HTTP is a protocol for communicating with a web server. Option D is incorrect because RDBMS is a database NOT a communication protocol.

37
Option A is incorrect because SQL does NOT generate dynamic HTML content. Option B is correct because SQL has a data definition language that supports the creation of RDBMS tables and views. Option C is correct because SQL includes the SELECT statement that supports reading data from relational databases. Option D is incorrect because JDBC is Java technology's interface to relational databases, NOT SQL.

38
Option A is correct because JMS is used to communicate with messaging services asynchronously.
Rodovia Pref. Luiz Salomo Chamma, S/N Km 41 Pouso Alegre CEP 07895-340 Franco da Rocha SP Brasil - Telefones (11) 4443-6110/4449-3115 E-mail: etefrancodarocha@hotmail.com Site: http://www.etecfran.com.br/ 22

Anlise de Programao

Profor: Gilberto Braga de Oliveira

Option B is incorrect because SQL is the standard language to communicate with a database. Option C is incorrect because HTTP is a protocol for communicating with a web server. Option D is incorrect because RDBMS is the name for a relational database management system.

39
Option A is incorrect because HTML by itself does NOT provide any UI functionality. Option B is incorrect because HTML applications are distributed automatically by the web server so they are easy to maintain. Option C is incorrect because HTML applications do NOT require a JRE plug-in to execute. Option D is correct because HTML applications are distributed automatically by the web server so they are easy to maintain.

40
Option A is correct because HTML provides only static features: text formatting, layout, generation of user interfaces. Option B is correct because HTML provides only a limited set of user interface components. Option C is incorrect because HTML does provide navigation capabilities, such as hyperlinks. Option D is incorrect because HTML does provide rich text formatting capabilities, such as tables and cascading style sheets.

41
Option A is incorrect because J2ME applications can NOT execute in web browsers. Option B is correct because the MIDP v2.0 specification supports playing audio and the generation of tones. Option C is correct because J2ME applications usually execute on small devices with small screen resolution, which cannot support rich UI components. Option D is incorrect because MIDP v2.0 supports over-the-air provisioning: this is NOT an automatic feature. That is, applications do NOT automatically update when the user selects the application.

42
Option A is incorrect because an Applet executes within a security sandbox that, by default, prohibits access to the user's filesystem. Option B is correct because an Applet might fail to execute correctly (or at all) if the web browser does NOT have the appropriate JRE installed. Option C is incorrect because an Applet does NOT have access to the web browser's cookie information. Option D is incorrect because the default security sandbox does permit communication with the originating enterprise server.
Rodovia Pref. Luiz Salomo Chamma, S/N Km 41 Pouso Alegre CEP 07895-340 Franco da Rocha SP Brasil - Telefones (11) 4443-6110/4449-3115 E-mail: etefrancodarocha@hotmail.com Site: http://www.etecfran.com.br/ 23

Anlise de Programao

Profor: Gilberto Braga de Oliveira

43
Option A is incorrect because Applets execute in a security sandbox that does NOT permit access to files on the client system. Option B is incorrect because Applets can be used to create animated games. However, Applets do NOT have access to gaming-specific APIs like J2ME applications do. Option C is correct because Applets execute in a security sandbox that prohibits connections to arbitrary Internet servers. However, Applets may connect to the server that delivered the Applet to access media files on that server. Option D is correct because Applets can access other Applets on the page through the AppletContext object supplied by the web browser.

44
Option A is correct because Swing has a broader GUI component set than AWT. Option B is incorrect because MIDP is a J2ME (not J2SE) profile. Option C is incorrect because JSF is a J2EE web-based UI component framework with only a limited component set. Option D is incorrect because AWT has a more limited GUI component set than Swing. Option E is incorrect because SWT is NOT a standard J2SE technology.

45
Option A is incorrect because JSP is used to create dynamic HTML content. It does NOT handle business logic. Option B is correct because JMS is the technology that handles asynchronous requests and performs the business logic of these requests. Option C is incorrect because JDBC is a database communication technology and does NOT handle business logic. Option D is incorrect because JNDI is a naming and directory service interface. It does NOT handle business logic.

46
Option A is incorrect because JNDI and JDBC support completely independent purposes in an application. JNDI is an interface to directory servers and JDBC is an interface to database servers. Option B is incorrect because servlets and SQL support completely independent purposes in an application. Servlets respond to HTTP requests and SQL is used to communicate with relational databases. Option C is correct because JavaMail uses SMTP (simple mail transfer protocol), which is used to send email from an application to users. Option D is incorrect because JavaScript and EJB support completely independent purposes in an application. JavaScript provides interactivity to web pages and Enterprise JavaBeans provide business logic.

47
Rodovia Pref. Luiz Salomo Chamma, S/N Km 41 Pouso Alegre CEP 07895-340 Franco da Rocha SP Brasil - Telefones (11) 4443-6110/4449-3115 E-mail: etefrancodarocha@hotmail.com Site: http://www.etecfran.com.br/ 24

Anlise de Programao

Profor: Gilberto Braga de Oliveira

Option A is correct because JSP (JavaServer Pages) technology mixes HTML syntax and dynamic elements (such as Java code and action tags) to create dynamic web pages. Option B is incorrect because JSP technology is a server-side technology. JavaScript is the client-side technology that supports web page interactivity. Option C is incorrect because JSP technology is NOT intended to be used to create business components. Option D is correct because JSP technology is ideal for web designers who are NOT familiar with Java programming. Option E is incorrect because JSP technology is NOT an integration technology.

48
Option A is incorrect because this definition describes a MIDlet developer. Option B is correct because this definition describes a servlet developer. That is, servlets are components that handle HTTP requests. Option C is incorrect because this definition describe a JSP developer. Option D is incorrect because this definition describes an entity bean developer.

49
Option A is incorrect because JSP is NOT an EJB technology. Option B is incorrect because servlets are NOT an EJB technology. Option C is incorrect because MDBs do NOT record client conversational state. Option D is correct because stateful session beans are used to record client conversational state. Option E is incorrect because stateless session beans do NOT record client conversational state.

50
Option A is incorrect because entity beans are used to represent persistent data. Option B is incorrect because message-driven beans handle asynchronous events. Session beans only handle synchronous events. Option C is correct because session beans represent business processes and stateless session beans are client-independent. That is, they do NOT store conversational state. Option D is incorrect because session beans do NOT exist in the web container.

51
Option A is incorrect because J2EE provides a rich and flexible programming model, but it is NOT simple. Option B is correct because J2EE infrastructure provides rich concurrency support in both the web and EJB tiers, which supports highly scalable application development. Option C is incorrect because clustering is NOT directly supported by the J2EE specification. However, most vendor implementations of J2EE do support clustering.
Rodovia Pref. Luiz Salomo Chamma, S/N Km 41 Pouso Alegre CEP 07895-340 Franco da Rocha SP Brasil - Telefones (11) 4443-6110/4449-3115 E-mail: etefrancodarocha@hotmail.com Site: http://www.etecfran.com.br/

25

Anlise de Programao

Profor: Gilberto Braga de Oliveira

Option D is correct because declarative transaction management is a required feature of the EJB container. Option E is incorrect because this functionality is NOT part of the J2EE specification.

Rodovia Pref. Luiz Salomo Chamma, S/N Km 41 Pouso Alegre CEP 07895-340 Franco da Rocha SP Brasil - Telefones (11) 4443-6110/4449-3115 E-mail: etefrancodarocha@hotmail.com Site: http://www.etecfran.com.br/

26

You might also like