You are on page 1of 56

1. Which of the following is EJB System Exception? 1.javax.ejb.ObjectnotFoundException 2. javax.ejb.EJBException 3. javax.ejb.DuplicateKeyException 4. javax.ejb.CreateException 2.

Possible to iterate multiple times over an iterator (True or false) 3. class Classname { public static void main(String[] args) { int[][] a1 = {[1,2,3],[4,5,6],[7,8,9,10]}; System.out.print(a1[0][2]+","+a1[1][0]+","+a1[2][1]); What is output? Check.. He declared array elements in [].. Compilation Error -> answer

4. class Classname { public static void main(String[] args) { int[][] a1 = {{1,2},{3,4,5},{6,7,8,9},{}}; for (int i = 0; i < a1.length; i++) { System.out.print(a1[i].length+","); }}} What is the result of attempting to compile and run the program? a.Prints: 2,3,4,0, b. Prints: 1,2,5,0, c. Compile-time error d. Run-time error e. None of the above 5. Is there any method allows to look next element in an iterator(iterator interface) without advancing the iterator?ans:d a. yes,Iterator.peek b. yes, .next c. no such methods d. none of the above

-1-

6. Which of the following are valid types of persistent fields in cmp2.0 a. either collection or set b. classes implement java io serializable c. java primitives d. entity bean local interface 7.. public Class AQuest{ Public void method (object o){ SOP(Object Version) } Public void method(String S){ SOP(String Version); PSVM(String arg[]){ AQuest q= new AQuest(); q.method(null); What will be output? a.Object Version b.String Version c.compilation fails d.runtime error e. compiles but no output 8. This ques is from SCJP book Collection chapter back Ques: Given: public static void main(String[] args) { Queue<String> q = new LinkedList<String>(); q.add("Veronica"); q.add("Wallace"); q.add("Duncan"); showAll(q); } public static void showAll(Queue q) { q.add(new Integer(42)); while (!q.isEmpty()) System.out.print(q.remove() + " "); } What is the result? A) Veronica Wallace Duncan B) Veronica Wallace Duncan 42 C) Duncan Wallace Veronica D) 42 Duncan Wallace Veronica E) Compilation fails. F) An exception occurs at runtime.

-2-

9.

which the following methods are used in EJBQL Like that.(choose 2) a) Select method. a) finder method. a) Remove method. a) Business object method.

10. Which of the following produces a compile time error? a) int arr[][];//1 b) int []arr[];//2 c) int []arr[];//3 None of the above 11. String str =abc; Str.concat(def); Str.concat(gh); SOP(str); a)compile time error. b)abcdefgh; c)abc; 12. No of finally blocks allowed for a try-catch block.. a) always 1 b). 0 or 1 13. Given six numbers as a[]=1.6,8.9,-9.6,2.0,0.9,3.5 The output is required as 1.6,-9.6,2.0,8.9,0.9 Four options with code in it are given The codes differs in only one line A sort function like sort(a,0,4) sort(a,0,3) sort(a,1,3) like that 14. A question on core Java with Options a). All Objects have a length method. b). Every object has a equals method. (Every object in java also has a hash code method) c) Every object has a sort method

15.

class Level1Exception extends Exception {} class Level2Exception extends Level1Exception {} class Level3Exception extends Level2Exception {} class Purple { public static void main(String args[]) { int a,b,c,d,f,g,x; a = b = c = d = f = g = 0; x = 3;

-3-

try { try { switch (x) { case 1: throw new Level1Exception(); case 2: throw new Level2Exception(); case 3: throw new Level3Exception(); } a++; } catch (Level2Exception e) {b++;} finally {c++;} } catch (Level1Exception e) { d++;} catch (Exception e) {f++;} finally {g++;} System.out.print(a+","+b+","+c+","+d+","+f+","+g); }} 011001 16. Find the o/p class A{ psvm(){ try{ badMethod(); s.o.p("A"); } catch(Exception e){ s.o.p("B"); finally{ s.o.p("C"); } s.o.p("D"); } static void badMethod(){} }

options : a). Compile time error b). runtime exception c). ACD d). AD 17. Find the o/p class A{ psvm(){ try{ badMethod(); s.o.p("A");

-4-

} catch(Exception e){ s.o.p("B"); finally{ s.o.p("C"); } s.o.p("D"); } static void badMethod(){ throw RuntimeException; } } options : a). Compile time error b). runtime exception c). ACD d). AD

18. which is correct? a). vectors synchronized. Array lists are not (Array lists are also heterogenous) b). vectors are heterogeneous array lists are not 19. Class A, Class B extends A, Class C extends B.A method doIt() is implemented in all classes. How to call doIt() of A with an instance of C. a). Super.doIt(); b.) this.doIt(); Both the options will cause compilation error 20. In EJB 3.0,all are Plain Old Java Objects(POJO)-T/F -> TRUE 21. class Exception1 extends Exception{} class Exception2 extends Exception1{} class Exception3extends Exception2{} class Exception4extends Exception3{} public class Test{ int a,b,c,d,f; int x=5; try{ switch(x){ case 1: throw new Exception1(); case 2: throw new Exception1(); case 3: throw new Exception1(); case 4: throw new Exception1(); } a++;

-5-

}catch(Exception1 e){ b++;} catch(Exception e){c++} finally{d++} f++; } } System.out.println(a++b+c+d++f); } 10011 22. package Base; Class Base{ protected void murari(); } public class Test extends Base.Base{ public static void main(String args[]){ Test t= new Test(); t.murari(); } } What is the output? a) Test class cannot find method in Base classs murari(); b) No errors.. Answer: compilation fails 23. class A{ void method() throws ArithmeticException{ } } public class C extends A { void method() throws InterruptedException{ System.out.println("String"); } public static void main(String []args){ } } -6-

Which is correct? a). method() in C class shouldnt throw InterruptedException b). method() in C class should throw ArithmeticException

24.

Which of the following statement is False regarding Tightly Encapsulation? A). Inner class follows Tightly Encapsulation b) Anonymous class follows Tightly Encapsulation

Inner classes and anonymous classes in java cannot follow tight encapsulation. Both of the above options are false.

25. Given a properly prepared String array containing 5 elements which range of results could a proper invocation of arrays.binarysearch() produce -6 Through 4 (See the question with option -6 to 4. ( It is is collection question From SCJP 1.5 Book)

26. See the question with options a). Queue<String>x=new PriorityQueue<String>; b). LinkedList<String>x=new LinkedList<String>; . ( It is is collection question From SCJP 1.5 Book) 27. Tasks using a reference to EJBHome (i) create & remove Session Bean (ii)get a handle to Session Bean (iii)create but not remove

28. import java.util.*; class GFC102 { public static void main (String args[]) { Object a = new HashSet(); System.out.print((a instanceof Set)+","); System.out.print(a instanceof SortedSet); }} What is the result of attempting to compile and run the program? True False 29. import java.util.*; class GFC102 {

-7-

public static void main (String args[]) { Object a = new treeSet(); System.out.print((a instanceof Set)+","); System.out.print(a instanceof SortedSet); }} What is the result of attempting to compile and run the program? True True 30. What do enterprise beans use to communicate with the EJB container to get runtime context information? The javax.ejb.EJBContext provided by the container A JNDI ENC context A javax.ejb.EJBHome object provided by the container A javax.ejb.EJBMetaData object provided by the container

31. The bean class for an entity that uses the EJB 2.0 model of container-managed persistence: Must implement java.io.Serializable Is only used for better integration with popular IDEs Must be abstract Must not be abstract

32. At what point, precisely, in the life-cycle is a container-managed entity bean considered created? Immediately prior to the execution of its ejbCreate() method Immediately after the execution of its ejbCreate() method After the CMP bean's data has been committed to the underlying persistent datastore During the execution of its ejbPostCreate() method 33. What is a deployment descriptor? An XML file format used by the container to learn about the attributes of a bean, such as transactional characteristics and access control A method for transporting enterprise beans back and forth between systems An XML file used by enterprise bean clients to learn about the attributes of a bean, such as access control and transactional characteristics. A format for bundling enterprise beans for delivery to customers

34. RuntimeException re=null;

-8-

Throw re; What will be output? Exception in thread "main" java.lang.NullPointerException

35. cust1= LocalCustomercust1; Cust2= LocalCustomercust2; If(cust1.IsIdentical(cust2)) { If(cust2.IsIdentical(cust1)) { S.O.P(true true); } Else S.O.P(false true); If(cust1.IsIdentical(cust1)) { S.O.P(true false); } } What is output? a). true true b). false true c). true false... (The question is not clear. But this is the answer for this question)

Title: SCBCD for the java 2 plat form , Enterprise Edition, Exam: 310-090, Version: 12-08-05 From the above PDF document

36 Which two can a Bean Provider do if the OnMessage() of a MDB encounter an application problem. (In SCBCD PDF see Question No: 41) Add the application exception to the methods throw clause Handle the exception in the method; do not throw the exception Wrap and rethrow the exception as javax.ejb.EJBException Wrap and rethrow the exception as javax.ejb.RemoteException

-9-

37 Which two statements about session beans with a remote client view are true? (In SCBCD PDF see Question No: 55) The Bean Provider must implement the get EJBObject method The Bean Provider must create a class that implements EJBObject The Bean Provider is not responsible for implementing the handle classes The Bean Provider must guarantee that an ejbRemove method is implemented in the bean class The bean provider is responsible for ensuring that one thread can be executing an instance at a time 38 Which statement about the EJB 2.0 container in passivation beans is true? (In SCBCD PDF see Question No: 60) The container must be able to save and restore a beans reference to a java:comp/env JNDI context across the beans passivation and activation 39 Which transaction attribute may cause a javax.transaction.TransactionRequiredException to be thrown? (In SCBCD PDF see Question No: 69) Mandatory 40 From which method can a Bean Provider legally invoke create() method on a beans own EJB object reference? (In SCBCD PDF see Question No: 82) ejbPostCreate 41 Which statement is true about purpose of EJB QL? (In SCBCD PDF see Question No: 126) EJB QL is used to implement the home methods 42 Which statement describes characteristics method permission defined by declarative secure? <method-permission> -> describes which role may call a method <security-role> - > describes a role used in method permissions (<Security-role-ref> for mapping the roles to respective individuals or for linking security roles) 43 public class CreditCard { private String cardID; private Integer limit; public String ownerName; public void setCardInformation(String cardID, - 10 -

String ownerName, Integer limit) { this.cardID = cardID; this.ownerName = ownerName; this.limit = limit; } } Which statement is true? A. The class is fully encapsulated. B. The code demonstrates polymorphism. C. The ownerName variable breaks encapsulation. D. The cardID and limit variables break polymorphism. E. The setCardInformation method breaks encapsulation 44 Through which of the following interface does an application create, find and remove enterprise beans? 1. javax.ejb.EJBHome 2. javax.ejb.EJBObject 3. javax.ejb.EntityBean 4. javax.rmi.Remote 45 Which of the following is correct about MDB? 1. Can execute in client transactional context 2. All messages from the client services by the same MDB 3. MDBs do not have a client visible identity 4. MDB can hold Client Conversation state 46 Which is not a typical action of a catch block? 1. Partial processing of the exception 2. Complete handling, 3. Throwing exceptions 4. Rethrow same exception to the calling environment 47 What is the function of isIdentical() method? Returns true if two stateless session beans are from the same home Returns false if two stateful session beans are from the same home 48 Which of the following is the requirement of the message driven bean? Correct Answers: 1) Must implement MessageDrivenBean and MessageListener interface 2) Class must be public 3) Class cannot be abstract or final 4) Must implement 1 onMessage method 5) Must implement one ejbCreate and one ejbRemove method 6) Must -> public constructor with no args 7) Must not define finalize method

- 11 -

The correct answer should be any one or more of the above options 49 class Classname { public static void main(String[] args) { int[][] a1 = {{1,2,3},{4,5,6},{7,8,9,10}}; System.out.print(a1[0][2]+","+a1[1][0]+","+a1[2][1]); }} What is the result of attempting to compile and run the program? a. Prints: 3,4,8 b.Prints: 7,2,6 c. Compile-time error d. Run-time error e. None of the above

50 public class Base {} class Sub extends Base{} class Sub2 extends Base{} public class CEx{ public static void main (String argv[]){ Base b= new base(); Sub s= (sub)b; } } Run Time error Exception in thread "main" java.lang.ClassCastException: cts.dove.com.A at cts.dove.com.SuperClass.main(SuperClass.java:21)

51 Private class Base{ Base(){ Int i=100; SOP(i); } } PSVM(){ Pri p=new pri(); SOP(i); } } What is the output? a. 200 b. 100 c. 100 followed by 200

- 12 -

d. Error 52 prototype of default constructor Public class Test{} a. test(void) b. test() c. Public Test() d. Public Test Void() e. Public Test (void) 53 Which of the following are valid types of persistent fields in cmp2.0 a. either collection or set b. classes implement java io serializable c. java primitives d. entity bean local interface 54 Which valid delivery modes supported in JMS (any 2) a. Durable b. Permanent c. Non-persistence d. Persistence http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/jms/package-summary.html

55 Class Base{ PSVM(string arg[]){ SOP (Hello) Public class Test extends Base{} What is the output? a) compilation fails b) Hello c) Runtime d) No output (If the class name is Test.java) If the class name is Base.java -> compilation fails) The public class Test must be defined in its own file

56 Application Exception a. javax.ejb.NoSuchObjectLocalException b. javax.ejb.duplicatekey c. javax.ejb.TransactRolledback d. javax.ejb.TransactRequiredload.

- 13 -

57 What must be included in the <resource-ref> tag a. <environment resource> b. <res-type> c. resources -env-ref> d. <res-ref-name> 58 J2EE support distributed transaction ans:a a.True b.False 59 Collection that maintains unique element is called a. Hashset b. LinkedList c. ArrayList d. Vector 60 Which statement is correct? a. Exception in case of VM shutdown,if a try block starts to execute a corresponding finally block must always run to completion b. Exception in case of VM shutdown,if a try block starts to execute a corresponding finally block will start to execute. c. An error that might be thrown in a methiod must be declared as thrown by that method or be handled within that method. d. Multiple catch can catch same class of exception more than once. e. A try statement must have atleat one catch block. 61 Super(),this() this serves as a reference to the current object whilst super refers to the super class of the current object. This keyword can be used inside the methods and constructors Recall that the this keyword has two meanings: to denote a reference to the implicit parameter and to call another constructor of the same class. Likewise, the super keyword has two meanings: to invoke a superclass method and to invoke a superclass constructor. When used to invoke constructors, the this and super keywords are closely related. The constructor calls can only occur as the first statement in another constructor. The construction parameters are either passed to another constructor of the same class (this) or a constructor of the superclass (super). Either super() or this() should be the first call in a constructor but not both.

- 14 -

Refer to http://www.informit.com/articles/article.aspx?p=1021579 62 . Bean provider takes if the onMessage method of the MDB encounters an application exception If the bean method encounters a runtime exception or error, it should simply propagate the error from the bean method to the container. If the bean method performs an operation that results in a checked exception that the bean method cannot recover, the bean method should throw the javax.ejb.EJBException that wraps the original exception. Any other unexpected error conditions should be reported using javax.ejb.EJBException (javax.ejb.EJBException is a subclass of java.lang.RuntimeException).

Answers: 1) Handle the exception in the method; do not throw the exception 2) Wrap and rethrow the exception as javax.ejb.EJBException http://docs.sun.com/app/docs/doc/819-4721/6n6rrfqsj?a=view 63 Java.com prefix access 1) Query Iterators 2) Filters 3) Pattern Matching Extensions. It can access preference information by querying. It can edit preferences and validate preference values. http://www.ociweb.com/jnb/jnbAug2006.html

64 CMP entity bean retrieves primary key through a) EntityContext.getIdentity() b) EntityContext.getPrimaryKey() c) Bean.getPrimaryKey() d) Bean.getIIdentity() 65 Both session and entity beans can implement local and remote client views, and generally the same considerations apply. However, an entity bean must implement a local client view in what situation? a. When the application uses message-driven beans. b. When the entity bean is a target of a container-managed relationship.

- 15 -

c. When the entity bean is located in a different JVM from the client. d. When the application uses a session bean as a facade to a set of entity beans. 66 If you use container-managed transaction demarcation, you can set a message-driven bean to participate in a transaction. To ensure that message delivery from the message destination to the message-driven bean is part of the subsequent transactional work, set the message-driven beans transaction attribute (in the deployment descriptor) to ans: C a. NotSupported b. Mandatory c. Required d. Supports 67 Difference between Iterator and ListIterator? a) Iterator -> Iterate element in the forward direction, List Iterator -> Iterate element in the bi-directional direction. b) Iterator -> Iterate element in the bi-directional direction, List Iterator -> Iterate element in the forward direction. c) Iterator -> Iterate element in the bi-directional direction, List Iterator -> Iterate element in the bi-directional direction. d) None of the above 68 class G03 {private String name;} class G04 { private String name; public int a1; public m1(){ sysout(1); } } class G05 { private String name; private int a1; private m2(){ sysout(2); } } Which class is tightly encapsulated? a) G04 b) G05 c) G06 d) None

69

12. public class AccountManager { 13. private Map accountTotals = new HashMap(); 14. private int retirementFund; 15. 16. public int getBalance(String accountName) {

- 16 -

17. Integer total = (Integer) accountTotals.get(accountName); 18. if (total == null) 19. total = Integer.valueOf(0); 20. return total.intValue(); 21. } 23. public void setBalance(String accountName, int amount) { 24. accountTotals.put(accountName, Integer.valueOf(amount)); 25. } } This class is to be updated to make use of appropriate generic types, with no changes in behavior (for better or worse). Which of these steps could be performed? (Choose three.) A) Replace line 13 with private Map<String, int> accountTotals = new HashMap<String, int>(); B) Replace line 13 with private Map<String, Integer> accountTotals = new HashMap<String, Integer>(); C) Replace line 13 with private Map<String<Integer>> accountTotals = new HashMap<String<Integer>>(); D) Replace lines 1720 with int total = accountTotals.get(accountName); if (total == null) total = 0; return total; E) Replace lines 1720 with Integer total = accountTotals.get(accountName); if (total == null) total = 0; return total; F) Replace lines 1720 with return accountTotals.get(accountName); G) Replace line 24 with accountTotals.put(accountName, amount); H) Replace line 24 with accountTotals.put(accountName, amount.intValue()); Ans : B , E, and G are correct 70 . Class Alpha(){ } Class Beta extends Alpha{ Beta(){ Sysout(Beta);

- 17 -

} Public static void main(String args[]){ new Alpha(); new Beta(); } } What is the output when the program is complies? a) BetaBeta b) Beta c) Compilation fails d) Run time error . 71 Question from EJB-QL : I didnt remember the ques correctly but the options given below are correct... Which statement are correct like that (choose 2) a) select object(A.balance) from account A where ABS(A.balance) GT 1000.0 b) select object(A.balance) from account A where ABS(A.balance) > 1000.0 c) select object(A.balance) from account A where ABS(A.balance) > 1000.0 d) select object(A.balance) from account A where SQRT(A.balance) > 1000.0 72 void test(){ Sysout(test); Print(); } Public void print(){ } Public static void print() { } What is the output of the above program? a) methods are duplicated. b) Test method will call one or more print() method. c) Compilation fails. -> duplicate methods found 73 Which of the following is correct ? a) <security-role-ref> <role-name>manager</role-name> <role-link>xyz</role-link> </security-role-ref> b) <security-role-ref> <role-name>manager</role-name> </security-role-ref> c) <security-role-ref> <role-link>xyz</rele-link> </security-role-ref> 74 which the following are used in EJBQL Like that.(choose 2) a) Select method.

- 18 -

a) finder method. a) Remove method. a) Business object method. 75 Class A{ Public static void main(String args[]){ int a1[][] = { {1,2},{2,3,4},{4,5,6,7} ); sysout(Print:+ a1.length); } } What is the output? a) Print:0 b) Print:3 c) Print:5 d) Print:4 76 Which of the following are collection classes? a) vector b) Hashset c) Collection d) Iterator 77 which methods are in both EJBHome and EJBLocalHome? a) void remove(Handle h) b) void remove(Object PrimaryKey) c) get EJBMetaData() d) get HomeHandle

78 Class A11{ Public string tostring() { sysout(A11); } } Class A12{ Public static void main(String args[]){ All a1[] = new A11[1]; All a2[][] = new A11[2][]; All a3[][][] = new A11[][][]; a1[0] = new A11(); a2[0] = . = 0; a3[..] = a3[] = a1; sysout(a3[4][3][..]); ----> they asked to print the value of some 3d array } } Options are like this a) null b) All c) compile time error

- 19 -

d) runtime error 79 Public static void main(String args[]){ try{ if(args.length==0) return; sysout(args[0]); } finally{ sysout(Print); } } } I didnt remember the option.. Options are like a) arrays out of bound exception b) If no argument is given it prints the stmt in finally block c) If one argument is given it prints the argument followed by the finally stmt. d) If one argument is given it prints the argument alone. 80 Question based on try-catch block. Class A{ Public static void main(String args[]){ int k=0; int i; try{ int i=1/k; }catch{Arithmetic exception ae){ Sysout(1); catch(RuntimeException r){ sysout(2); } catch(Exception e){ sysout(3); } finally{ sysout(4); } Sysout(5); } } What is the output? a) prints 1,4,5 in the order b) prints 2,4 in the order and some other options. 81 int a1[]={1,2} int a2[]={3,4,5} int a3[]={6,7,8,9} sop(a1[0][1]+","+a2[1][2]+","+a3[2][3]); 2, 5, 9

- 20 -

82 Which of the following produces a compile time error? a) int arr[2][2];//1 b) int [3]arr[3];//2 c) int [2]arr[3];//3 83 String str =abc; Str.concat(def); Str.concat(gh); SOP(str); a)compile time error. b)abcdefgh; c)abc; 84 JNDI Look Up in a)EJB Context b)JNDI Context 85 if( string.toString.equals(string)) Sop(true) else Sop(false) Ans : True 86 UDDI is ____________ a)Only Registry b)only repository c)both 87 Java 1.5 written in basic or Java or not? 88 Small amount of data is available,rapid access is needed sort is not required.unique values are not required. Which will you use? a)Hash Map b)Tree Set c)Linked List d)Array 89 Passivate in EJB To send the bean from the ready state to the pooled state. ejbPassivate(). It is a container call back method. The container must be able to save and restore a beans reference to a java:comp/env JNDI context across the beans passivation and activation

- 21 -

90 U need to enter 5 Phone Numbers and only two of them are known.the other three names would be entered and the numbers would be null.. Four options with a long code are given.. Only thing u need to select is the collection i.e Tree Map Hash Table..Hash Map 91 Fail Fast Iterator In Java or not If yes it is related to Synchronized or Unsynchronized. fail-fast term is about Java collections and theirs iteration and modification, which are not synchronized. http://www.javafaq.nu/java-article988.html 92 Question on Container Managed Bean Auto Generated Primary Key.. optional flag to use automatic generation of primary key automatic-pk optional flag to specify the name of automatic cmp field generate for pk autogenerated automatic-pk-field-name If you specify a java.lang.Object as the primary key class type in <prim-key-class>, but do not specify the primary key name in <primkey-field>, then the primary key is auto-generated by the container 93 A question on core Java with Options Every Object has a length method. Every object has an equals() method. (Every java object has an equals() and a hashCode() method) http://www.ibm.com/developerworks/java/library/j-jtp05273.html 94 Does List collection provide list iterator? TRUE (http://java.sun.com/docs/books/tutorial/collections/interfaces/list.html)

95 Questions on pooled bean like which bean can be considered a part of pooled beans.. Their characteristics.. Stateless session beans -> pooled beans Entity Beans -> pooled beans, cached beans Stateful session beans -> only cached beans Message driven beans -> pooled

- 22 -

http://docs.sun.com/source/819-0084-10/pt_tuningas.html

96 Message driven bean: what methods will it use for passing messages - > onMessage(javax.jms.Message msg) 97 class Level1Exception extends Exception {} class Level2Exception extends Level1Exception {} class Level3Exception extends Level2Exception {} class Purple { public static void main(String args[]) { int a,b,c,d,f,g,x; a = b = c = d = f = g = 0; x = 3; try { try { switch (x) { case 1: throw new Level1Exception(); case 2: throw new Level2Exception(); case 3: throw new Level3Exception(); } a++; } catch (Level2Exception e) {b++;} finally {c++;} } catch (Level1Exception e) { d++;} catch (Exception e) {f++;} finally {g++;} System.out.print(a+","+b+","+c+","+d+","+f+","+g); }} What is the result of attempting to compile and run the program? Prints: 0, 1, 1,0,0,1 98 Should finally block always follow the last catch block..(t/f) False 99 User defined Exceptions -> Custom Exceptions User Defined Exceptions (Checked Exceptions) Class Not Found Exception Clone Not Supported Exception AWT Exception IO Exception File Not Found Exception EOF Exception

- 23 -

Interrupted IO Exception Run Time Exceptions (Unchecked Exceptions) Arithmetic Exception Null Pointer Exception Index Out Of Bounds Exception No Such Element Exception 100 which methods should not be used by container managed beans Methods used by container managed beans -> ejbcreate, ejbremove, ejbactivate and ejbpassivate (for stateful session beans) and setsessioncontext, setmessagedrivencontext and setentitycontext (for respective beans) 101 T/F Does EJB provides support for nested transactions -> False 102 - The EJB QL question (Its there in questions from sun links) 103 which of the following communications are allowed in EJB options : point to point send receive broadcast receive Answers: 1) Publish and Subscribe 2) point to point http://www.ibm.com/developerworks/websphere/library/techarticles/0304_yu/yu1.ht ml 104 If array contains two elements which are equal then after using Arrays.sort method index of elements will get changed. Answer -> False http://www.leepoint.net/notes-java/data/arrays/70sorting.html 105 Find the o/p RunTimeException re = null; throw re; ans: Option containing NullPointerException 106 Find the o/p class A{ psvm(){ try{

- 24 -

badMethod(); s.o.p("A"); } catch(Exception e){ s.o.p("B"); finally{ s.o.p("C"); } s.o.p("D"); } static void badMethod(){} } options : Compile time error runtime exception ACD AD 107 Find the o/p class Base { void abstract method(){}; } class Child extends base { //some code dont remember } Options: Compile time error Runs and prints o/p Ans: abstract method declaration contains {} 108 Find the o/p Class Base { Base() { int i = 1; s.o.p("i : "+i); } } class Child extends Base { public i; child(int i) { super(i); s.o.p(i); }

- 25 -

psvm() { sop(new Child(5)); } } The parent class was not having constructor with 1 argument (integer type). Compilation error 109 class Base { static x=1; Base() { x+=1; } } class Child extends Base { Child() } Compilation Fails 110 Collection Question where queue was created as following Queue q<String> = new List(); q.add("A"); q.add("B"); q.add("c"); then, there was one method void method(Queue q) { q.add(new Integer("42")); } psvm() { q.reverse(); while(q.hasNext) { s.o.p(//code for printing element); } } Compilation Fails. Interfaces cannot be instantiated (They have instantiated the List interface in the above code)

- 26 -

111 class superclass{ private void method(){ } Class subclass extends superclass{ Public void method(){ } Public static void main(String []a){ subclass s=new subclass(); s.method(); } Which method is invoked ie. method present in superclass or subclass 112 class come{ Public static void main(String []a){ Try{ Int i=0; Int y=5/0; }catch(Exception e){ } catch(ArithmeticException e){ } }

What will be the output? Compilation Error (Unreachable catch block for Arithmetic Exception) 113 class base{ base(int i){ } } Class sub extends base{ Sub(){ } Sub(int i){ } Public void method(){ } How to invoke the constructor present in base class from subclass Calling super(i) from either Sub() or Sub(int i) 114 what are the unique features of List. It can have duplicates Positional Access Search Iteration (Iterator and List Iterator) Range-view

- 27 -

http://java.sun.com/docs/books/tutorial/collections/interfaces/list.html 115 Class Exception1 extends Exception{} Class Exception2 extends Exception{} Class test{ p.s.v.m (){ try{ } catch(Exception2 2){} Catch(Exception1 e){} Catch(Exception e){} } Public void method() throws Exception1{ Throw new Exception1 (); } } Regarding flow Compilation Error

116 which of the following st are true? (a) overriding method must have the same signature as overridden method (b) overriding method can throw exceptions which are not present in overridden method three more options are there The Overriding method must have the same signature, same arguments (Argument list and Argument order) and same return type as that of the overridden method 117 multidimensional arrays listing of elements like a1[]={2,3} a2[]={2,3,4} a3[]={3,4,5,6} a[][]={a1,a2,a3} then the ques will be like sop(a[0][1]+","+a[1][2]+","+a[2][3]) Then they ask you the output It can be compilation error 13 16 3,4,6

- 28 -

118 difference between hashtable and hashmap Hashtable - > Should not contain null values, It is synchronized. HashMap - > May contain null values, and is not synchronized 119 which is synchronized---vector and hash table are synchronized. Others are not synchronized. 120 which collection is best for inserting the value in middle Linked list Linked List -> Slowest Access and Fastest Insertion 121 which collection is worst for inserting value in middle arraylist http://java.sun.com/developer/JDCTechTips/2002/tt0910.html 122 Arrays.sort one question ---answer is sort 1, 3 123 Inheritance one theoretical ques like inheritance means has a relationship false Inheritance means IS-A Relationship 124 Message driven bean needs 2 interfaces i.e. messagedrivenbean and messagelistener 125 Which i/f provides Slowest/Fastest access to middle element? Slowest - Linked list Fastest - Array List http://java.sun.com/developer/JDCTechTips/2002/tt0910.html 126 Class of exceptions tat is unchecked Arithmetic, FileNotFound, -> Checked Exception (File Not Found is a sub-type of IO Exception) Runtime, All 127 class B{ psvm(String args[]) { (s.o.p(Hello); } } Public class T extends B{} a) Compilation fails b) Hello

- 29 -

c) Runtime d) No output (If the file name is T.java) Compilation fails if the class name is B.java, because the public class T must be defined in its own type

128 Differences bw ArrayList and vector which is synchronized and asynchronized, which one contains heterogeneous elements Array list is not synchronized. Vector is synchronized. Both Array List and Vector can contain heterogeneous elements. 129 Transactions in EJB ->Nested transactions are not allowed, Parallel transactions are not allowed, EJB supports transactions for all the bean types. EJB also supports security. EJB supports distributed transactions and security. 130 What all given below are thrown by throw statement Error Object Exception Throwable Runtime Exception 131 Vector can be deleted by which method: Delete method Remove method 132 Session Bean can have zero create method-T/F -> False 133 Class A, Class B extends A, Class C extends B.A method doIt() is present. How to call doIt() of A with an instance of C. Super.doIt(); this.doIt(); Both the options will cause compilation error 134 if((new Object))(.equals((new Object) and some 2 lines code and asked whether this will return true or false. False 135 A superclass A is defined and a subclass B is defined which extends A and one more class is defines which extends B. Is it possible to invoke the method of class A using the object of Class C Using super keyword.

- 30 -

False 136 public class C { void method(String s){ System.out.println("String"); } void method(StringBuffer s){ System.out.println("String Buffer"); } public static void main(String []args){ C c = new C(); c.method(null); } } Answer: Compilation error (The method (String) is ambiguous) for type C 137. class A{ void method() throws ArithmeticException{ } public class C extends A { void method()throws InterruptedException{ System.out.println("String"); } public static void main(String []args){ } }

Answer: we should remove interrupted exception 138 class A{ Message msg = new Message(); } public class C extends A { void method(){ System.out.println(?); } public static void main(String []args){ C c = new C(); c.method(); } } class Message{ String text = "hello"; } How do you access text in Message class and print in the method() in Class C

- 31 -

Options:msg.text,super.msg.text.object.super.msg.text Answer : msg.text and super.msg.text 139 public class C { public static void main(String []args){ String baz = args[3]; System.out.println(baz); } } Given the Arguments java test red green blue Answer:Run time Exception ArrayIndex out of Bounds Exception 140 Differntiate ArrayList and Vector a) ArrayList is synchronised but vector is not. b) Vector is synchronised but ArrayList is not. c) Arrays store heterogeneous objects but vector doesnot d) Vector store heterogeneous objects but Arrays doesnot Answer :B 141 Vector contains Heterogeneous objects. State true or False Answer:True 142 public class C{ public static void main(String []args){ String sad = null; sad.concat("bha"); sad.concat("rat"); System.out.println(sad); } } Answer: RunTime Exception null pointer Exception 143 String sad = "bharat"; sad.concat("bha"); sad.concat("rat"); System.out.println(sad); answer:bharat 144 String sad = "bharat"; String asd = sad.concat("bha"); System.out.println(asd); Answer:bharatbha

- 32 -

145 public class C{ public static void main(String []args){ if(args.length==0){ sytem.out.println("hi") return; System.out.println(args[0]); } } Four options are there....CHeck box ...asked to mark two options.... If there is no argument it will print hi If one argument ...it will print that argument 146 class TestException extends Exception{ } class FlyingException extends TestException{ void method() throws TestException{ } } public class C{ public static void main(String []args){ FlyingException c = new FlyingException(); try { c.method(); } catch (FlyingException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } Answer: Compilation Error TestException should present in the Flying Exception 147 How many Finally blocks can a try-catch block have? Answer:0 or 1 148 class level1exception extends Exception{ } class level2exception extends level1exception{ } public class level3exception extends level2exception{ public static void main (String [] args){ int x=2; int a=b=c=d=f= 0; try{ switch(x) {

- 33 -

case 1: { throw new level1exception(); } case 2: { throw new level2exception(); } case 3: { throw new level3exception(); } } }catch(level3exception e){ a++; } catch(level2exception e){ b++; } catch(level1exception e){ c++; } finally{ d++; } f++; System.out.println(a+","+b+","+c+","+d+","+f); } } 01011 149 public class level3exception{ public static void main (String [] args){ Set s = new TreeSet(); s.add("2"); s.add("3"); s.add("1"); System.out.println(s); } } Answer: [1, 2, 3] 150 Question on Iterator...Check Box which of the following atr true? 1)Iterator is member of Java Collection Framework 2)Iterator is the replacement of Enumeration in Collection Framework. 151 EJB timer objects are like stateless session beans? True or False 152 char c=new char[1],byte b=new byte[1], float f=new flota[1],object obj=new object[1] sysout(c[1],b[1],f[1],obj[1]); Array Index Out of Bounds Exception 153 what bean provider should declare in deployment descriptor? 1. Class name -> specifies the fully classified name of the bean class 2. Bean name -> specifies a beans name 3. Transaction type -> Specifies the transaction management type of an EJB (bean- or container-managed). http://sarwiki.informatik.hu-berlin.de/Bean_Provider's_Responsibilities

- 34 -

154 what class should be used for bean to provide programatic security ? 1.EJB metadata context 2.client meta data security An application component provider accesses programmatic security for EJB and Web components with J2EE platform security APIs. Javax.ejb.EJBContext -> Answer http://www.googleperson.wideopen.com/docs/manuals/rhaps/jonas-guide/s1security-sec-programmatic.html 155 a collection can refer itself ? true or false 156 methods in EJB home and local home interfaces EJBHome getEJBMetaData() getHomeHandle() remove(Handle handle) remove(obj PK) EJBLocalHome remove(obj PK) 157 which bean is used to embody business objects 1.enterprise bean 2.entity bean 3.session bean 158 What does the EJB specification architecture define? A. Transactional components B. Distributed object components C. Server-side components D. All of the above 159 How can client prepare itself for callbacks from the RMI server? Extend java.rmi.server.UnicastRemoteObject Call UnicastRemoteObject.exportObject() Either of the above two will work. 160 int []a1={1,2,3} int[]a2={3,4,5}

- 35 -

int[]a3={6,7,8,9} int[][]a={a1,a2,a3} sysout(a[0][1],a[0][2],[0][3]) 2, 5, 9 161 class c extends B B extends A all implemnts the method doit() then how can we cal the doit() method in A from c options are like super.doit(),super.this.doit() Neither of the above options will work.

162. In Test.java class Base{ public static void main(string args[]){ public void amethod(){ System.out.println(Hello); } } public class Test extends Base{} What is the output of the program? The code compiles and runs with out any output Compilation fails -> (public void amethod()) Runtime error is thrown The code compiles and prints Hello 163 private class A{ //some code here } public class B extends A{ public static void main(String args[]){ } } Compilation Error -> Private Class A 164 valid array declarations int [] a1[], a2[] ,a3[]; int [][]a1, a2[]; int []a1[]; All the above declarations are valid. Invalid declaration -> int []a1, []a2; -> some thing like this. The [] in an array can come either after the identifier or after the type.

- 36 -

165 class Test{ private int cardID; private int cardNumber; public String name; public void setCardID(int cardID){ this.cardID=cardID; } public int getCardID(){ return cardID; } public void set cardNumber (int cardNumber){ this. cardNumber = cardNumber; } public int get cardNumber (){ return cardNumber; } } Which of the following statement is true? The variable name violates the encapsulation Like that four options are given. I think the above option is correct. 166 four classes are given with some variables and methods. And asked to find which classes violate the encapsulation. Class which does not contain private data members (private instance variables) will violate the Encapsulation -> for example, public String name; This type of declaration will violate encapsulation. 167 class A{ int I=0; public A(String s){ i=1; } } class B extends A{ public B(int i){ I=2; } } public class C extends B{ public static void main(String args[]){ C c=new C(); System.out.println(i); }

- 37 -

ans: four options are given. But all the options are given. I think it will give compilation error. But the options are very close, if it is compilation error also due to which reason the error is try to see that also. Compilation Error

168 class Base{ public Integer method(Integer i){ return new Integer(100); } public Long method(Long l){ return new Long(200); } } public class Test{ public static void main(String args[]){ Base b=new Base(); b.method(5); } } For this questions I dont remember the options exactly. Compilation Fails 169 Difference between Vector and Array list Vector -> Synchronized Array List -> Not Synchronized 170 class Exception1 extends Exception{} class Exception2 extends Exception1{} class Exception3extends Exception2{} class Exception4extends Exception3{} public class Test{ int a,b,c,d,f; int x=5; try{ switch(x){ case 1: throw new Exception1(); case 2: throw new Exception1();

- 38 -

case 3: throw new Exception1(); case 4: throw new Exception1(); } a++; }catch(Exception1 e){ b++;} catch(Exception e){c++} finally{d++} f++; } } System.out.println(a++b+c+d++f); } in the above question value of x is 5 it is not matching with any of the cases in switch. 10011 171 Class Base{ //some code here } public class Test extends Base{ public static void main(String args[]){ // some code here } } I dont remember the code exactly. But it is like without compiling the base class test class can get the functionality of the base class. True 172 package com.base; class Base{ Protected String name; // some more code } package com.Test; class Test extends Base{ public static void main(String args[]){ // some code here } } but in the above code the Base class is not imported in the Test class. The options are very close. Due to which reason it gives the compilation error. Remember that compilation error also

- 39 -

Compilation Error 173 what will happen if catch is not there and only finally is there Will continue normally or terminate 174 what happens when calling base constructor when u dont have local constructor The compiler will create a no-argument default constructor only. In order to invoke a constructor with some arguments inside the base class, a matching constructor type should be created explicitly in the derived class 175 when a ejb object is in pooled state we need to bring to active state what all methods need to call ejbCreate(), ejbPostCreate() and ejbActivate() 176 equals and hashcode Equals() returns true -> hashcode() must return true Equals() returns false-> hashcode() might return false Hashcode() returns true -> Equals() might return true Hashcode() returns false -> Equals() must return false

177 bean can use both bmp and cmp at the same time - true or false -> false CMP and BMP beans can be used in the same application and a bean can be CMP or BMP, but not both at the same time. They are mutually exclusive. http://faqs.javabeat.net/ejb/enterprise_java_beans_ejb_interview_questions_4.php

178 message driven bean is stateless or stateful -> stateless 179 how many instances of mdb can run at a time -> many instances can run in parallel 180 vector is heterogenous true or false -> True 181 can tostring used to convert object to string -> True 182 byte[] b=new byte[1]; int[] i=new int[1]; long[] l=new long[1]; Object[] o=new Object[1]; System.out.println(b[0]+" "+i[0]+" "+l[0]+" "+o[0]); Ans: 0 0 0 null

- 40 -

183 Class which allow bean programmatic security (i) javax.ejb.EJBContext (ii) javax.ejb.EJBMetaData (iii) javax.ejb.Security (iv) javax.ejb.ClientMetaData Ans: (i) 184 Tasks using a reference to EJBHome (i) create & remove Session Bean (ii)get a handle to Session Bean (iii)create but not remove 185 FailFastIterator in Java (i) No failFastIterator concept in Java (ii)FailFastIterator helps in iterating and conditioning..... 2 more options .. don remember fail-fast term is about Java collections and theirs iteration and modification, which are not synchronized. http://www.javafaq.nu/java-article988.html

186 Tasks by application assembler (i)Bind a Resource manage connection factory reference with... (ii) Assign Resource manage connection factory to..... 2 more options .. don remember To link an enterprise bean reference to a target enterprise bean 187 Session bean Passivation (i)container cannot remove a bean in passivated state (ii)must call stateless session bean ejbPassivate method b4 moving it to bean pool. (iii) isIdentical () called for passivation 1 more option .. don remember Passivation and activation are only for stateful session beans. Not for stateless session beans. For entity beans, bean cannot be removed after passivation. Results in orphaned rows in the database table. The method used is ejbPassivate(). It is a container call back method. The container must be able to save and restore a beans reference to a java:comp/env JNDI context across the beans passivation and activation -> Answer

- 41 -

188 Locating or using a Session bean's Home Interface (correct stmts) (i)Client can acquire a handle for bean's Local Home Interface (ii) Acquiring Initial Context required for remote clients (iii)Once acquired by client, can be used multiple times (iv)Initial Context must be narrowed b4 used. 189 Which java.util.classes & interfaces support event handling? (i)EventObject (ii)EventListener (iii)Both (iv)None http://www.geekinterview.com/question_details/25 190 Valid message models in JMS (i)send/receive (ii)broadcast/receive (iii)publish/subscribe (iv)point-to-point Ans: (iii) and (iv)

191 EJB timer service used with (i) CMP (ii)CMP, BMP, MSD (iii)MSD (iv)CMP,BMP 192 Iterator is class true false Iterator is an interface 193 String str=null; str.append("RAJ"); str.append("kumar"); s.o.p(str); Compilation Error -> The method append(String) is undefined for the type String. In the above code, if append is replaced by concat, then a Null Pointer Exception will be thrown.

194 Collection will extend Cloneable and Serializable Interface? (T/F) false 195 Diff b/n HashTable and HAsh Map---hashtable is ordered version of hashmap..

- 42 -

ans:HashTable does not allow null values & it is Synchronized. HashMap allows one null key and multiple null values in a collection. Hash Map is not synchronized. 196 Hash Set s=new Hash Set();--unordered unsorted. a) s is instanceOf Set-----true b) s is instanceOf SortedSet----false Options: 1) true false 2) false false like this 197 package mypack; class C { C() { System.out.println("Default"); } C(String i) { System.out.println(i); } } class B extends C { B(String s) { //super(s); System.out.println(s); } B() { this("1", "2"); System.out.println("Mytest"); } B(String s1, String s2) { this(s1 + s2); } } public class A extends B { public static void main(String[] args) { B b = new B("Test"); } } Ans: Default Test In above ques is Super in class B is not commented then o/p is Test Test 198 An Abstract class can extend a non-abstract class (T/F) ans: True 199 Correct about session beans a) Session beans can be private b) Session beans can be final -> session bean cannot be final

- 43 -

c) Session beans allow overloading -> method overloading is allowed in EJB

200 valid array declaration of an array choose three a) int[] a[],b[]; b) int []a,b[]; c) int[] a,b[]; d) int[][] a,b[]; I did't remember the exact options All the above options are correct Invalid declaration -> int []a1, []a2; -> some thing like this. The [] in an array can come either after the identifier or after the type. 201 following are valid collection classes a) List Bag b) Hash Map c) Vector d) Set List 202 True about arrays (increases or decreases) -> decreases size of array increases performance insertion, deletion time Increasing the size of an array will decrease its performance. 203 Question on when to use throw and throws Throws is used along with a method signature to specify that a particular method may throw an exception. A method signature must declare the type of exceptions that it is expected to throw in throws clause. A throw statement specifies a particular exception being thrown. 204 Error error=new Error(); error is instanceOf Exception (T/F) false 205 package mypack; class Parent { Parent() { int i=2; } } public class Child extends Parent { Child(){

- 44 -

int i=1; } public static void main(String[] args) { Child b = new Child(); System.out.println(b.i); } } ans: compilation error 206 Which i/f provides Slowest/Fastest access to middle element? Linked list/Array List Slowest access -> Linked List Fastest access -> Array List 207 class B{ psvm(String args[]) { (s.o.p(Hello); } } Public class T extends B{} a) comp fails b) Hello c) Runtime d) No output 208 Class A{ Public static void main(String args[]){ int k=0; int i; try{ int i=1/k; }catch{Arithmetic exception ae){ Sysout(1); } catch(RuntimeException r){ sysout(2); } catch(Exception e){ sysout(3); } finally{ sysout(4);

- 45 -

} Sysout(5); } } What is the output? a) prints 1,4,5 in the order b) prints 2,4 in the order and some other options. 209 A superclass A is defined and a subclass B is defined which extends A and one more class is defines which extends B. Is it possible to invoke the method of class A using the object of Class C Using super keyword. -> False. It is not possible to invoke. 210 public class C { public static void main(String []args){ if("String".toString()=="String"){ System.out.println("Equal"); }else{ System.out.println("Not Equal"); } } } Answer: Equal 211 public class C { void method(String s){ System.out.println("String"); } void method(StringBuffer s){ System.out.println("String Buffer"); } public static void main(String []args){ C c = new C(); c.method(null);

- 46 -

} } Answer: Compilation error 212 class A{ void method() throws ArithmeticException{ } } public class C extends A { void method()throws InterruptedException{ System.out.println("String"); } public static void main(String []args){ } }

Answer: we should remove interrupted exception 213 class A{ Message msg = new Message(); } public class C extends A { void method(){ System.out.println(?); }

- 47 -

public static void main(String []args){ C c = new C(); c.method(); } } class Message{ String text = "hello"; } How do you access text in Message class and print in the method() in Class C Options:msg.text, super.msg.text.object, super.msg.text Answer: msg.text and super.msg.txt 214 In Test.java class Base{ public static void main(string args[]){ public void amethod(){ System.out.println(Hello); } } public class Test extends Base{} What is the output of the program. a) The code compiles and runs with out any output b) Compilation fails c) Runtime error is thrown d) The code compiles and prints Hello 215 class Base{ public Integer method(Integer i){ return new Integer(100); } public Long method(Long l){ return new Long(200); } } - 48 -

public class Test{ public static void main(String args[]){ Base b=new Base(); b.method(5); } } For this questions I dont remember the options exactly. Compilation Fails 216 Given some methods and asked to find vector methods Remove method is used for deletion Add method is used for adding the elements http://java.sun.com/j2se/1.4.2/docs/api/java/util/Vector.html 217 Given some methods and asked to find Object class methods The following are the methods in Object class: clone(), equals(Object), finalize(), getClass(), hashCode(), to String(), wait(), notify(), notifyAll(), wait(long), wait(long,int) http://bioportal.weizmann.ac.il/course/prog2/java/api/java.lang.Object.html

218 Given one collection object and changed the reference of it in the next line and asked whether it will through an error or not 219 Class A1{ } Class A2{ A1 [] a1= new A1[2] A1 [] [] a2 = new A1 [2][2] A1 [] [] [] a3=new A1 [2][2][2] SOP(a3[2][2][2]); Array Index Out of Bounds Exception 220 Consider an array List having same objects and it is sent for sorting. After sorting the arraylist will have the elements in the same order as that of before (True\False) -> False 221 As ArrayList size increases efficiency increases or decreases Increases efficiency 222 Class A{ Public static void main(String args[]){ If (args.length<4 && args[3].equals(-d)){

- 49 -

Sop{True); } else{ Sop(false); } What is the output of the above if the program is run with the following arguments? A B C d False 223 Session Bean can be private ( T\F) -> False 224 Given some statements regarding super constructer and asked to pick the correct one. (Answer: Super will be present implicitly inside a constructer if there is no argument constructor explicitly defined) 225 Method sort is present in collection class or collection interface ANS. Collections class http://java.sun.com/j2se/1.4.2/docs/api/java/util/Collections.html 226 Class A{ Public A(SringBuffer a){ SOP{String Buffer); } Public A(Sring a){ SOP{String ); } public static void main (String args[]){ A a1=new A(null); } } What is the output of the above : . Ans: Compilation error 227 One question on overriding.. Super class method has one return type Sub class overriding method has one return type.. asked to give the output. Ans: Compilation Error 228 Differences between vector and ArrayList Vector -> synchronized Array List -> not Synchronized

- 50 -

229 Which is synchronized.. hashmap\ hashtable ->Hash table 230 Which transaction attribute throws TransactionRequired Exception () Ans: Mandatory 231 Created two objects using EJB create methods. Asked whether two are equal or not.. 232 output of. String.toString().equals(String) and String.toString() = =String new Object().equals(new Object()) -> True, True and False

233 How can you remove an element from a Vector? 1) delete method 2) cancel method 3) clear method 4) remove method Answer 4) remove method

234 byte[] b=new byte[1]; int[] i=new int[1]; long[] l=new long[1]; Object[] o=new Object[1]; System.out.println(b[0]+" "+i[0]+" "+l[0]+" "+o[0]); Ans: 0 0 0 null 235 Tasks using a reference to EJBHome (i) create & remove Session Bean (ii)get a handle to Session Bean (iii)create but not remove 236 FailFastIterator in Java (i) No failFastIterator concept in Java (ii)FailFastIterator helps in iterating and conditioning..... 2 more options .. don remember

- 51 -

fail-fast term is about Java collections and theirs iteration and modification, which are not synchronized. http://www.javafaq.nu/java-article988.html

237 EJB timer service used with (i) CMP (ii)CMP, BMP, MSD (iii)MSD (iv)CMP,BMP

238 Correct about session beans a)Session beans can be private b)Session beans can be final c)Sesson beans allow overloading etc 239 array list contains values 1.6, 2 ,0.9, 0.2, 3, 1to get the output 1.6, 0.2, 0.9, 2, 3, 1 Which of the following statements must be executed. That means a part of the list must be sorted and should be printed. All the options contain the same method but the argument values are changing. So see this method which performs the above sorting. Sort(a,1,3) 240 What is the output of the program if the base class is not compiled . Class Base{ //some code here } public class Test extends Base{ public static void main(String args[]){ // some code here } } I dont remember the code exactly. But it is like without compiling the base class test class can get the functionality of the base class. 241 package com.base; class Base{ Protected String name; // some more code }

- 52 -

package com.Test; class Test extends Base{ public static void main(String args[]){ // some code here } } but in the above code the Base class is not imported in the Test class. The options are very close. Due to which reason it gives the compilation error. Remember that compilation error also. Compilation error

242 Requirements of Message Driven Bean Correct Answers: 1) Must implement MessageDrivenBean and MessageListener interface 2) Class must be public 3) Class cannot be abstract or final 4) Must implement 1 onMessage method 5) Must implement one ejbCreate and one ejbRemove method 6) Must -> public constructor with no args 7) Must not define finalize method The correct answer should be any of the above options

243 About this() and super() Either this() or super() should be the first statement inside a constructor If super() is the first line in a constructor, the second must be this() The compiler always inserts super() as the first statement in a constructor. 244 Int a[][]={{1,2},{3,4,5},{6,8,9,0}); s.o.p(a[0][0]+ , +a[1][1]+,+a[2][2]); Ans: 1, 4, 9 245 Class One{ Public One(){this(1)} Public One(String s){this(s+4,base);} Public One(String a, String b){sop(a+b);} } Public class Two{ Public Two(){sop(sub);}

- 53 -

Public Two(int a){super(); Sop(sub);} Psvm(){ Two two=new Two(2); } } Ans: Prints 14base sub

246 Differentiate ArrayList and Vector 1) ArrayList is synchronised but vector is not. 2) Vector is synchronised but ArrayList is not. 3) Arrays store heterogeneous objects but vector doesnot 4) Vectors store heterogeneous objects but Arrays do not

247 public class C{ public static void main(String []args){ if(args.length==0){return; } System.out.println(args[0]); } } Four options check box type...choose two Ans: If run with no arguments it wont print anything If run with one or more arguments it will print the 1st argument 248 Public class A{ Psvm(String args[]) { try{ int i=0; int ans=15/i; }catch(Exception e){} Catch(Arithmetic exception){} } } Ans: Compilation Error (A narrower Exception cant follow a broader Exception in the catch blocks)

249 When is a Container Managed Beans primary key Auto Generated? Ans: If you specify a java.lang.Object as the primary key class type in <prim-keyclass>, but do not specify the primary key name in <primkey-field>, then the primary key is auto-generated by the container

- 54 -

250 Given: Public static void before() { Set set = new TreeSet (); set.add("2"); set.add(3); set.add("1"); Iterator it = set.iterator (); while (it.hasNext()) System.out.print (it. next () + " "); } Which of the following statements are true? A. The before() method will print 1 2 B. The before() method will print 1 2 3 C. The before() method will print three numbers, but the order cannot be determined. D. The before() method will not compile. E. The before() method will throw an exception at runtime.

251 Is the fail fast iterator in java synchronized or unsyncronized? Ans: Unsynchronized 252 EJB create remove begin methods will be present in a)EJB Home b)EJB OBJ c)EJB Caller Principal Ans : a 253 Given a[]=1.6,8.9,-9.6,2.0,0.9,3.5 The output required is 1.6,-9.6,8.9,2.0,0.9,3.5 A sort function like sort(a,0,4) sort(a,0,3) sort(a,1,3) like that Ans: sort(a,1,3) 254 A question on Core Java with options like a)Every Object has a length method. b)Every Object has a equals method. c)Every Object has a sort() method d)None of these 255 Which of the following is an application Exception NOsuchObjectException ----system Exception EJBException ------------------system Exception RemoteException------------ system Exception None of these APPLICATION EXCEPTIONS include the following 1.createException

- 55 -

2.DuplicatekeyException 3.FinderException 4.ObjectNotFoundException 5.RemoveException

256 Map m=new TreeMap(); Sop(m instanceof collection) Ans: False 257 What executes EJB components(EJB container wasnt an option) 1)Application server 2)EJB server 3)Web server 4)Database Server 258 which two elements must be included in the resource ref tag? <session> <resource-ref> <resource-ref> <session> Ans:<res-type> , <res-ref-name> 259 When a transaction is rolled back on occurrence of a system exception which of the following occurs? a) The container removes the bean. -> The bean will be simply discarded. b) An exception is thrown to the user c) The exception is rethrown as an remote Exception 260 Correct form of deployment descriptor snippet Ans : <servlet> ... <security-role-ref> <role-name>cust</role-name> <role-link>bankCustomer</role-link> </security-role-ref> ... </servlet> 261 Valid messaging models Ans: point to point, publish/subscribe

- 56 -

You might also like