Anda di halaman 1dari 8

1. What is a thin-client application? A. A browser that uses a plug-in to process user data. B.

A distributed application where the client program does not process data, but instead passes data for processing to an enterprise bean running on an application server. C. An application that cannot be stopped by a firewall. D. An application compiled with the -thin option of the javac command. 2. What is a J2EE component? A. Special icons for creating the user interface elements for thin clients. B. A data module saved to the component area of the database. C. A self-contained functional software unit that is assembled into a J2EE application and interfaces with other application components. D. A JAR file. 3. What advantage does an entity bean have over a session bean?
A. Entity bean data survives crashes. B. An entity bean represents non-persistent data. C. It creates its own JAR file during deployment. D. You get authentication code without having to write any.

4. When do you use a session bean?


A.When you want to be certain your application data persists between program invocations, even in the event of a crash. B.If you need to initiate a database transaction. C.To process transient data that can be re-created in the event of a crash. D.To keep people who do not know how to program from accidentally changing important logic code.

5. Why would you design a J2EE application so user data is entered by way of a JavaServer Page and managed by an underlying JavaBeans class? A. To make the user interface more interesting. B. To simplify application deployment. C. To prevent malicious programs from gaining access to sensitive information on your database server. D. To make the application much easier to update, maintain, and manage. 6. Why is XML a good way to transfer text-based data from one program or tool to another? A. XML imposes important limitations on the receiving program or tool. B. The receiving program or tool can use the XML tagging information to determine how to best handle the incoming data. C. XML tags offer an extra level of security. D. XML tags specify to the receiving program or tool exactly how to format and display the data.

7. What part of the J2EE platform handles data storage and retrieval on behalf of a containermanaged entity bean? A. The thin client. B. Deployment descriptors. C. The JAR file. D. The bean's container

8. What is bean-managed persistence? A. When you implement entity or session bean methods to use SQL commands you provide. B. When the bean's container handles data storage and retrieval. C. When the J2EE server is never shut down. D. When changes to database data are lost during a crash.

9. How are life cycle methods called? A. By thin clients. B. By calls to the database. C. By the J2EE server. D. By the bean's container. 10. In a multitiered application, which tier is the browser in? A. First tier. B. Second tier. C. Third tier. D. Fourth tier.

11. Which code declares class A to belong to the mypackage.financial package? A) package mypackage;package financial; B) import mypackage.*; C) package mypackage.financial.A; D) import mypackage.financial.*; E) package mypackage.financial;

12. Which one of the following statements is FALSE? A) Java supports multi-threaded programming. B) Threads in a single program can have different priorities. C) Multiple threads can manipulate files and get user input at the same time. D) Two threads can never act on the same object at the same time. E) Threads are created and started with different methods.

13. Which one of the following is a valid declaration of an applet? 1) Public class MyApplet extends java.applet.Applet { 2) Public Applet MyApplet { 3) Public class MyApplet extends applet implements Runnable { 4) Abstract class MyApplet extends java.applet.Applet { 5) Class MyApplet implements Applet {

14. If(check4Biz(storeNum) != null) {} Referring to the above, what datatype could be returned by method check4Biz()? 1) Boolean 2) int 3) String 4) char 5) byte

15. Your application supports multiple client types including HTTP clients. Your business layer is implemented using Enterprise Java Beans. Which of the following is best suited for maintaining client state? a. b. c. d. e. Stateful session beans Entity Beans HttpSession attributes Cookies URL Rewriting

16. What is the result of attempting to compile and run this ? public class Test { public static void main(String[] args){ String s = "HelloWorld".substring(5,10); System.out.println(s); } } 1. The code will fail to compile. 2. Compile and run printing out "orld". 3. Compile and run printing out "oworl" 4. Compile and run printing out "World" 5. Run time exception

QUESTION : 17 Select one right answer. ----------------------What is the result of attempting to compile and run this ? 1. public class Test { 2. public static void main(String[] args){ 3. Test t = new Test(); 4. char c = 4 * 4; 5. String s = "bead"; 6. s = t.pearl(s); 7. System.out.println(Byte.parseByte(s,c)); } 8. String pearl(String s){ 9. return s.substring(0,1); } } 1. Compiler error caused by line 4. 2. Compiler error caused by line 7. 3. Compiler error caused by line 9. 4. Compiles and throws a NumberFormatException at runtime. 5. Compiles and runs printing out a number. 6. Compiles and runs printing out an alphabet.

A. Is wrong because it is legal to assign integer literal to a char variable as long as the value does not exceed the range of a char. B. Is wrong because parseByte(String s , int radix) will accept any native numeric type that is not wider than an int. C. 3 and 6 are just nonsense. D. 4. Is wrong because the the character b falls within the radix range specified by the second parameter.

QUESTION : 18 What is the value of d that will be printed out. public class Test { public final static void main(String[] args) { double d = - 22.22222; System.out.println(Math.ceil(d)); } } 1. 22 2. 22.0 3. -22 4. -23 5. -22.0 6. 23.0

QUESTION : 19 What is the result of attempting to compile and run this ? public class Test { public static void main(String[] args) { StringBuffer a = "Hello"; StringBuffer b = a.append("World"); System.out.println(a); } } 1. 2. 3. 4. 5. 6. It will print "World" It will print "HelloWorld" It will print "Hello World" The code will not compile. It will print "Hello" It will throw a runtime exception

QUESTION : 20 What is the result of attempting to compile and run this ? public class Test { public static void main(String[] args){ byte a = 10; Byte b = new Byte(a); Byte c = new Byte(11); System.out.println(b.compareTo(c)); } } 1. Compiler error 2. Runtime error 3. Runs and prints "false" 4. Runs and prints "0" 5. Runs and prints "1" 6. Runs adn prints "-1"

QUESTION : 21 What is the result of attempting to compile and run this ? public class Test { public static void main(String[] args){ Float f = new Float(16/0); System.out.println(f.isNaN()); } } 1. Compiler error 2. Runtime error 3. Runs and prints "false" 4. Runs and prints "true"

QUESTION : 22 What is the result of attempting to compile and run this ? public class Test { public static void main(String[] args){ Number n = new Number(16); Float f = new Float(16); System.out.println(n.equals(f)); } } 1. Compiler error 2. Runtime error 3. Runs and prints "false" 4. Runs and prints "true"

QUESTION : 23 What is the result of attempting to compile and run this ? public class Test { public static void main(String[] args){ Integer i = new Integer(256); System.out.println(i.byteValue()); } } 1. Compiler error 2. Runtime error 3. Runs and prints "256" 4. Runs and prints "0" 5. Runs and prints "127"

24. What best describes the appearance of an application with the following code? import java.awt.*; public class FlowAp extends Frame{ public static void main(String argv[]){ FlowAp fa=new FlowAp(); fa.setSize(400,300); fa.setVisible(true); } FlowAp(){ add(new Button("One")); add(new Button("Two")); add(new Button("Three")); add(new Button("Four")); }//End of constructor

}//End of Application 1) A Frame with buttons marked One to Four placed on each edge. 2) A Frame with buutons marked One to four running from the top to bottom 3) A Frame with one large button marked Four in the Centre 4) An Error at run time indicating you have not set a LayoutManager 25. How do you indicate where a component will be positioned using Flowlayout? 1) North, South,East,West 2) Assign a row/column grid reference 3) Pass a X/Y percentage parameter to the add method 4) Do nothing, the FlowLayout will position the component

26.What will happen when you attempt to compile and run this code? class Base{ abstract public void myfunc(); public void another(){ System.out.println("Another method"); } } public class Abs extends Base{ public static void main(String argv[]){ Abs a = new Abs(); a.amethod(); } public void myfunc(){ System.out.println("My func"); } public void amethod(){ myfunc(); } } 1) The code will compile and run, printing out the words "My Func" 2) The compiler will complain that the Base class is not declared as abstract. 3) The code will compile but complain at run time that the Base class has non abstract methods 4) The compiler will complain that the method myfunc in the base class has no body, nobody at all to looove it 27) Why might you define a method as native? 1) To get to access hardware that Java does not know about 2) To define a new data type such as an unsigned integer 3) To write optimised code for performance in a language such as C/C++ 4) To overcome the limitation of the private scope of a method

28. Which of the following statements about events are correct? (2 answers) [a] Event objects are placed on a Queue, where they are fetched by subscribers (objects of classes which implement the interface Subscriber). [b] The listener of an event must implement the method public void listen(EventObject obj). [c] Each event object must be an object of a subclass of EventObject. [d] Each event listener can investigate about the source of an event by calling the method getSource() on the event object. 29. How can you serialize an object? (a) You have to make the class of the object implement the interface Serializable. (b) You must call the method serializeObject() (which is inherited from class Object) on the object. (c) You should call the static method serialize(Object obj) from class Serializer, with as argument the object to be serialized. (d) You dont have to do anything, because all objects are serializable by default.

30. Given the following piece of code: public class MyThread extends Thread{ public String text; public void run(){ System.out.print(text); } } public class Test{ public static void main(String args[]){ MyThread t1 = new MyThread(); t1.text = "one "; MyThread t2 = new MyThread(); t2.text = "two "; t1.run(); t2.run(); System.out.print("three "); } } Which of the following statements is true? (a) If you execute this program, the result is always one two three (b) If you execute this program, the result is always three one two (c) The result of this program is undetermined. (d) Compilation will fail.

Anda mungkin juga menyukai