testking.sun.310 081.exam.q.and.a.30.03.06 arnebook

100
Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4 Exam Type: SUN Exam Code: 310-081 Total Questions: 254 Page 1 of 100 © TestKing.net Question: 1 Given: AnInterface is an interface. AnAdapter0 is a non-abstract, non-final class with a zero argument constructor. An Adapterl is a non-abstract, non-final class without a zero argument constructor, but with a constructor that takes one int argument. Which two construct an anonymous inner class? (Choose two.) A. AnAdapter1 aa = new AnAdapter1 () {} B. AnAdapter0 aa = new AnAdapter0 () {} C. AnAdapter0 aa = new AnAdapter0 (5) {} D. AnAdapter1 aa = new AnAdapter1 (5) {} E. AnInterface ai = new Anlnterface (5)) { Answer: B, D Question: 2 1. class A { 3. public String to String() { 4. return “4”; 5. } 6. } 7. class B extends A { 8. public String toString() { 9. return super.toString() + “3”; 10. } 11. } 12. public class Test { 13. public static void main (String[] args) { 14. System.out.printIn(new B()); 15. } 16. } What is the result? A. Compilation succeeds and 4 is printed. B. Compilation …………… is printed. C. An error on line 9 cause compilation to fail. D. An error on line 14 cause compilation to fail. E. Compilation succeeds but an exception is thrown at line 9. Answer: B Question: 3 Given: 1. public class Method Over { 2. public void set Var (int a, int b, float c) { 3. } 4. } Which two overload the set Var method? (Choose two.) A. private void set Var(int a, float c, int b) {}

Upload: vyacheslav-meshalkin

Post on 15-Sep-2015

7 views

Category:

Documents


1 download

DESCRIPTION

Testking.sun.310 081.Exam.q.and.a.30.03.06 Arnebook

TRANSCRIPT

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 1 of 100 TestKing.net

    Question: 1 Given: AnInterface is an interface. AnAdapter0 is a non-abstract, non-final class with a zero argument constructor. An Adapterl is a non-abstract, non-final class without a zero argument constructor, but with a constructor that takes one int argument. Which two construct an anonymous inner class? (Choose two.) A. AnAdapter1 aa = new AnAdapter1 () {} B. AnAdapter0 aa = new AnAdapter0 () {} C. AnAdapter0 aa = new AnAdapter0 (5) {} D. AnAdapter1 aa = new AnAdapter1 (5) {} E. AnInterface ai = new Anlnterface (5)) { Answer: B, D Question: 2 1. class A { 3. public String to String() { 4. return 4; 5. } 6. } 7. class B extends A { 8. public String toString() { 9. return super.toString() + 3; 10. } 11. } 12. public class Test { 13. public static void main (String[] args) { 14. System.out.printIn(new B()); 15. } 16. } What is the result? A. Compilation succeeds and 4 is printed. B. Compilation is printed. C. An error on line 9 cause compilation to fail. D. An error on line 14 cause compilation to fail. E. Compilation succeeds but an exception is thrown at line 9. Answer: B Question: 3 Given: 1. public class Method Over { 2. public void set Var (int a, int b, float c) { 3. } 4. } Which two overload the set Var method? (Choose two.) A. private void set Var(int a, float c, int b) {}

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 2 of 100 TestKing.net

    B. protected void set Var(int a, int b, float c) {} C. public int set Var(int a, float c, int b) {return a:} D. public int set Var(int a, int b, float c) {return a:} E. protected float set Var(int a, int b, float c) {return c:} Answer: A, C Question: 4 1. class A { 2. public byte file Number () { 3. return l; 4. } 5. } 6. 7. Class B extends A { 8. public short getNumber() { 9. return 2; 10. } 11. 12. public short getNumber() { 13. B b = new B(); 14. System.out.printIn(b.getNumber()); 15. } 16. } What is the result? A. Compilation succeeds and l is printed. B. Compilation succeeds and 2 printed. C. An error at line 8 cause compilation to fail. D. An error at line 14 cause complication to fail. E. Complication succeeds but an exception is thrown at line 14. Answer: C Question: 5 Given: 1. public class Foo { 2. public static void main(String[] args) { 3. StringBuffer a = new StringBuffer(A); 4. StrinbBuffer b = new StringBuffer(B); 5. operate (a, b); 6. System.out.printIn(a + , + b): 7. } 8. static void operate (StringBuffer x, StringBuffer y) { 9. y.append(x); 10. y = x; 11. } 12. } What is the result? A. The code compiles and prints A,B. B. The code compiles and prints A,BA.

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 3 of 100 TestKing.net

    C. The code compiles and prints AB,B. D. The code compiles and prints AB,AB. E. The code compiles and prints BA,BA. F. The code does not compile because + cannot be overloaded for StringBuffer. Answer: B Question: 6 1. public class X { 2. private static int a: 3. 4. public static void main (String [] args) { 5. modify (a) : 6. System.out.printIn(a) { 7. } 8. 9. public static void modify (int a) { 10. a++; 11. } 12. } What is the result? A. The program runs and prints 0 B. The program runs and prints 1 C. The program runs but aborts with an exception. D. An error possible undefined variable at line 5 cause compilation to fail. E. An error possible undefined variable at line 10 cause compilation to fail. Answer: A Question: 7 1. public class Test { 2. private static int j = 0; 3. 4. public static Boolean method B (int k) { 5. j + = k; 6. return true: 7. } 8. 9. public static void method A (int i) { 10. Boolean b; 11. b = I < 10 | method b (4): 12. b = I < 10 || methodb(8): 13. } 14. 15. public static void main (String args []) { 16. method A (0); 17. System.out.printIn(i); 18. } 19. } What is the result?

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 4 of 100 TestKing.net

    A. The program prints 0. B. The program prints 4. C. The program prints 8. D. The program prints 12. E. The code does not compile. Answer: B Question: 8 Which two are equivalent? (Choose two.) A. 16 > 4 B. 16 / 2 C. 16 * 4 D. 16 >> 2 E. 16 / 22 F. 16 >>> 2 Answer: DF Question: 9 Given: 1. public class X { 2. public static void main (String [] args) { 3. byte b = 1277; 4. byte c = 126; 5. byte d = b + C; 6. } 7. } Which statement is true? A. Compilation succeed and d take the value 253. B. Line 5 contains an error that prevents compilation. C. Line 5 throws an exception indicating out of range D. Line 3 and 4 contain errors that prevent compilation. E. The compilation succeed and d takes the value of 1. Answer: B Question: 10 Given: 8. int index = 1; 9. int[]foo = new int [3]; 10. int bar = foo [index]; 11. int baz = bar + index; What is the result? A. baz has a value of 0. B. baz has a value of 1. C. baz has the value of 2. D. An exception is thrown.

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 5 of 100 TestKing.net

    E. The code will not compile. Answer: B Question: 11 Given: 1. public class Test { 2. public static void main (String [] args) { 3. unsigned byte b = 0; 4. b--: 5. 6. } 7. } What is the value of b bat line 5? A. -1 B. 225 C. 127 D. Compilation will fail. E. Compilation will succeed but the program will throw an exception at line 4. Answer: D Question: 12 Given 1. public class Test { 2. public static void main (String[] args) { 3. String foo = args [0]; 4. String bar = args [1]; 5. String baz = args [2]; 6. } 7. } And command line is vacation: Java Test red green blue What is the Result? A. baz has the value of . B. baz has the value of null. C. baz has the value of red D. baz has the value of blue E. baz has the value of green F. The code does not compile. G. the program throws an exception. Answer: D Question: 13 Given: 1. //Point X 2. public class Foo { 3. public static void main (String [] args) throws Exception { 4. Print Writer out = new Print Writer (new

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 6 of 100 TestKing.net

    5. java.io.Output Stream Writer (System.out), true); 6. out.printIn (Hello) 7. } 8. } Which statement at Point X on line 1 allows this code to compile and run? A. import java.io.PrintWtier; B. include java.io.PrintWRiter; C. import java.io.OutputStream Writer; D. include java.io.OutputStream Writer; E. No statement is needed. Answer: A Question: 14 Which two method declarations are valid for an interface.? (Choose two) A. Public double methoda(): B. static void methoda(double d1) C. public final double methoda (); D. abstract public void methoda (); E. protected void methoda(double d1); Answer: AD Question: 15 1. package foo; 2. 3. import java.util.Vector 4. 5. private class My Vector extends Vector { 6. Int i = 1 7. public MyVector () { 8. i = 2; 9. } 10. } 11. 12. public class My New Vector extends my Vector { 13. public MyNew Vector () { 14. i = 4; 15. } 16. public static void main (String args []) { 17. MyVector v = new My New Vector (); 18. } 19. } What is the result? A. Compilation will succeed. B. Compilation will fail at line 5. C. Compilation will fail at line 6. D. Compilation will fail at line 14.

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 7 of 100 TestKing.net

    E. Compilation will fail at line 176. Answer: B Question: 16 Which four types of object can be thrown using the throw statement? (Choose four.) A. Error B. Event C. Object D. Exception E. Throwable F. Runtime Exception Answer: A, D, E, F Question: 17 Given: 1. public class Foo { 2. public static void main (String [] args) { 3. try { System.exit (0); } 4. finally { System.out.printIn(Finally):} 5. } 6. } What is the result? A. the program runs and prints nothing. B. The program runs and prints Finally. C. The code compiles. But an exception is thrown at runtime. D. the code will not compile because the catch block is missing. Answer: A Question: 18 Given: 1. Public class While Foo} 2. public static void main (Straing[] args) { 3. int x = I, y = 6 4. while ( y--) {x++:} 5. System, out. printIn (x = + x + y = + y): 6. { 7. { What is the result? A. The output is X = 6 y = 0 B. The output is x = 7 y = 0 C. The output is x = 6 y = -1 D. The output is x = 7 y = -1 E. Compilation will fail. Answer: E

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 8 of 100 TestKing.net

    Question: 19 Given: 6. 7. 8. And a custom tag handler for foo which extends Tag Support. Which two are true about the tag handler referneed by my Tag. (Choose two.) A. The do Start Tag method is called once. B. The do After Body method is NOT called. C. The EVAL_Page constant is a valid return value for the do End Tag Method. D. the EVAL_BODY_BUFFERED constant is a valid return value for the do Start Tag method. Answer: A, C Question: 20 Given 11. Public void services (Servlet Request request, 12. Servlet Response response) 13. throws 10 Exccption { 14. Servlet Context cxt = get Servlet Config ().get Servlet Context (): 15. Input Stream in = 16. insert code here 17. { Which statement. At line 16, retrieves an Input Stream for the file / WEBINF/myresrc.bin? A. ctx.get put Stream (/WEB-INF/myresrc.bin): B. ctx.get Input Stream (/WEB-INF/myresrc.bin): C. ctx.get Resource As Stream (/WEB-INF/myresrc.bin): D. new Input Stream (new Url (/WEB-INF/myresrc.bin): E. Get Class (). Get Resource As Stream (/WEB-INF/myresrc.bin): Answer: C Question: 21 Given an HttpServlet Request request and Http Servlet Response response, which sets a cookie username with the value joe in a servlet.? A. request.add Cookie (username. joe) B. request.set Cookie (username, joe) C. response.add Cookie (username, joe)) D. request.add Header (new Cookie (username, joe)) E. request.add Cookie (new Cookie (username, joe)) F. response.add Cookie (new Cookie (username, joe)) G. response.add Header (new Cookie (username, joe)) Answer: F Question: 22 Given:

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 9 of 100 TestKing.net

    10. public void service Servlet Request request. 11. Servlet Response response) { 12. ServletInput Stream sis= 13. //insert code here 14. } Which retrieves the binary input stream on line 13? A. request.get Writer (): B. request.get Reader (): C. request.get Input Stream(): D. request.get Resource As Stream(): E. request.get Resource As Stream (Servlet Request. REQUEST): Answer: C Question: 23 index.html: 16. 17. 18. 19. 20. MyServlet.java: 6. public void doGet (Http ServletRequest request. 7. HttpServletREsponseresponse_ 8. throws IOException. ServletExecption { 9. String first = request.getParameter )foo); 10. String second: 11. // your code here 12 } Which statement inserted at line II, retrieves the text from the second text field? A. second = request.getParameter (foo): B. second = request.getParameter (foo, 1): C. second = request.getParameter (foo,2): D. second = request.getParameter (foo) [1]: E. second = request.getParameter Values (foo) [1]: Answer: E Question: 24 Which HTTP method represents a request for information about the supported methods on an HTTP server? A. GET B. INFO C. HEAD D. TRACE E. OPTIONS Answer: E

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 10 of 100 TestKing.net

    Question: 25 Given the definition of MyObject and that an instance of MyObject is bound as a session attribute: 8. package com.example: 9. public class MyObject implements 10. javax-servlet.http.HttpSessionBindingListner{ 11. // class body code here 12. } Which is true? A. Only single instance of MyObject may exist within a session. B. The unbound method of the MyObject instance is called when the session to which it is bound times out. C. The com.example.MyObjectmust be declared as a servlet event listener in the web application deployment descriptor. D. The value Unbound method of the MyObject instance is called when the session to which it is bound times out. Answer: Pending. Send your suggestions at [email protected] Question: 26 Under what two circumstances is the set JspBody method NOT called in a tag class that implements the Simple Tag interface? (Choose two) A. The tag is invoked without a body. B. The doTAb method throws an exception. C. The element has the value empty. D. The tag is called with the attribute skip-body=true Answer: A, C Question: 27 Which two statements are true? (Choose two.) A. An inner class may be declared as static. B. An anonymous inner class can be declared as public. C. An anonymous inner class can be declared as private. D. An anonymous inner class can extend an abstract class. E. An anonymous inner class can be declared as protected. Answer: AD Question: 28 Which statements about static inner classes is true? A. An anonymous class can be declared as static. B. A static inner class cannot be a static member of the outer class. C. A static inner class does not require an instance of the enclosing class. D. Instance member of a static inner class can be referenced using the class name of the static

    inner class. Answer: C

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 11 of 100 TestKing.net

    Question: 29 Given: 1. public class MethodOver { 2. private int x,y: 3. private float z: 4. public vod set var (int a, int b, float c) { 5. x = a; 6. y = b; 7. z = c; 8. } 9. } Which two overload the setVar method? (Choose two.) A. void set Var Iint a, int b, float c) {

    x = a: y = b: z = c: }

    B. public void setVar(int a, float c, int b) { SetVar (a, b, c); }

    C. public void setVarIint a, float c, int b){ this(a, b, c); } C. public void setVar(int a, float c, int b) { This (a, b, c); }

    D. public void setVarIint a, float b) { X = a: Y = b: }

    E. public void setVar(int as, int by, float cz) { x = ax; y = by: z = cz: }

    Answer: BD Question: 30 Which two demonstrate an is a relationship? (Choose two.) A. public interface Person {} Public class Employee extends Person {} B. public interface Shape {} public interface Rectangle extends Shape {} C. public interface Color {} public class Shape { private Color color; } D. public class Species {} public class Animal { private Species species; } E. interface Component {}

    Class Container implements Component {

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 12 of 100 TestKing.net

    private Component [] children; Answer: B, E Question: 31 Given: 1. public class Test { 2. public static void leftShift(in i int j) { 3. i

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 13 of 100 TestKing.net

    3. String sl = new String (true); 4. Boolean bl new Boolean (true); 5. if (sl.cquals(bl)) { 6. System.out.printIn (Equal): 7. } 8. } 9. } What is the result? A. the program runs and prints nothing. B. The program runs and prints Equal. C. An error at line 5 cause compilation to fail. D. The program runs but aborts with an exception. Answer: A Question: 34 Given: 1. public class Test { 2. public static void main (String args []) { 3. Sytstem.out.printIn (6 3) : 4. } 5. } What the output? Answer: 5 Question: 35 Given: 8. String foo = blue; 9. boolcan [] bar = new Boolean [1]; 10. if (bar [0] { 11. foo = green; 12. } What is the result? A. foo has the value of B. foo hast he falue of null. C. foo has the value of blue D. foo has the value of green E. An exception is thrown. F. The code will not compile. Answer: C Question: 36 Which two are reserved words in Java? (Choose two.) A. run B. import C. default

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 14 of 100 TestKing.net

    D. implement Answer: B, C Question: 37 Given 1. public class Foo{ 2. public static void main (String [] args) { 3. Strings; 4. System.outprintIn (S=+s): 5. } 6. } What is the result? A. The code compiles and s= is printed. B. The code compiles and s= + s); C. The code does not compile because Strings is not initialized. D. The code does not compile because Strings cannot be referneed. E. The code comiles, but a NullPointer Exception is thrown when toString is called. Answer: C Question: 38 Which will declare a method that forces a subclass to implement it? A. public double methoda (): B. static void methoda(double d1) {} C. public native double methoda (): D. abstract public foid methoda (): E. protected void methoda (double d1) {} Answer: D Question: 39 Given: 1. public class Foo { 2. public void main ( String [] args ) { 3. System.out.printIn (Hello world.); 4. } 5. } What is the result? A. An exception is thrown. B. The code does not compile. C. Hello worlds. Is printed to the terminal. D. The program exits without printing anything. Answer: A Question: 40 Given 1. public class Exception Test {

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 15 of 100 TestKing.net

    2. class Test Exception extends Exception {} 3. public void runs Test () throws Test Exception {} 4. public void test () /* Point X*/{ 5. run Test (); 6. } 7. } At Point X on line 4, which code can be added to make the code compile? A. throws Exception B. catch (Exception e) C. throws Runtime Exception D. catch (Test Exception e) E. No code is necessary. Answer: A Question: 41 Given 1. public class for Bar { 2. public static void main (String [] args){ 3. int i = 0 and j = 5 4. tp: for (;;) { 5. i ++; 6. for (;;) 7. if (i > -- j) break tp: 8. } 9. System.out.printIn (i= + j = + j): 10. { 11. { What is the result? A. The program runs and prints I = 1 , j = 0 B. The program runs and prints I = 1 , j = 4 C. The program runs and prints I = 3 , j = 4 D. The program runs and prints I = 3 , j = 0 E. An error at line 4 cause compilation to fail. F. An error at line 7 cause compilation to fail. Answer: A Question: 42 Given the Tag: Assuming the tag referenced by my Tags: get Advice uses the Classic event model, which is true? A. The do After Body method is called. B. The doEnd Tag method is NOT called. C. The type attribute may be specified in the TLD D. The do Start Tag Method must always return SKIP_BODY. E. The TLD for this tag must NOT include a tag.

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 16 of 100 TestKing.net

    Answer: C Question: 43 Which two prevent a servlet from handling requests.? (Choose two.) A. The servlets init method returns a non-zero status. B. The servlets init method throws a Servlet Exception C. The servlets init method sets the Servlet Responses context length to 0 D. The servlets init method sets the Servlet Responses content type to null. E. The servlets init method does NOT return within a time period defined by the servlet container. Answer: B, E Question: 44 For an HttpServlet Response response, which two create a custom header? (Choose two) A. response.set Header (X-MyHeader. 34): B. response.addHeader (X-MyHeader. 34): C. response. Set Header (new Http Header (X-MyHeader. 34)): D. response.addHeader(new Http Header (X-MyHeader. 34)): E. response. addHeader (new Servlet Header (X-MyHeader. 34)): F. response. setHeader (new Servlet Header (X-MyHeader, 34)): Answer: A, B Question: 45 Which two HTTP methods are used to process from data in a servlet? (Choose two.) A. doGET B. doPut C. doPost D. doTrace E. doSubmit F. doProcess Answer: A, C Question: 46 A developer wants too use EL to invoke a function using S{my:bloof(foof)}. Which is always true? A. The method invoked by this function must be statie. B. The function class must implement the Function interface. C. The expression is NOT a valid EL expression for invoking a function. D. The function must be declared in a web.xml file using the element. E. The function class must have a method with the signature: Void bloof (java.lang.Strings) Answer: A Question: 47 Which two are characteristics of the Intercepting Filter pattern? (Choose two)

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 17 of 100 TestKing.net

    A. it provides centralized request handling for incoming requests. B. It forces resource authentication to be distributed across web components. C. It reduces coupling between presentation-tier clients and underlying business services. D. It can be added and removed unobtrusively, without requiring changes to existing code. E. It allows preprocessing and postprocessing on the incoming requests and outgoing responses. Answer: D, E Question: 48 1. class EnclosingOne { 2. public class InsideOne {} 3. } 4. public class InnerTest{ 5. public static void main(String[]args) { 6. EnclosingOne eo = new EnclosingOne(): 7. //insert code here 8. } 9. } Which statement at line 7 constructs an instance of the inner class? A. InsideOne ei = eo.new InsideOne(): B. eo.InsideOne ei= co.new InsideOne(): C. InsideOne ei = EnclosingOne.new InsideOne(): D. EnclosingOne.insideOne ei = eo.new InsideOne(): Answer: D Question: 49 Given: 1. class Base Class { 2. private float x = 1.0f; 3. protected void set Var(float f) { x = f;} 4. } 5. class SubClass extends BaseClass{ 6. private float x = 2.0f 7. //insert code here 8. } Which two are void examples of method overriding? (Choose two.) A. void setVar(float f) { x = f;} B. public void setVar(int f) { x =f;} C. public void setVar(float f) {return f;} D. public double setVar(float f) {return f;} E. protected float setVar() { x = 3.0f; return 3.0f; } Answer: C, E Question: 50 1. Class A {

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 18 of 100 TestKing.net

    2. public int getNumber(int a) { 3. return a + l: 4. } 5. } 6. 7. class B extends A { 8. public int getNumber(int a) { 9. return a + 2: 10. } 11. 12. public static void main (String args[] { 13. A a = new B(); 14. Systemout.printIn(a.getNumber(0)); 15. } 16. } What is the result? A. Compilation succeeds and 1 is printed. B. complication succeeds and 2 is printed. C. An error at line 8 causes compilation to fail. D. An error at line 13 causes complication to fail. E. An error at line 14 causes compilation to fail. Answer: B Question: 51 1. public class Test { 2. public static void string Replace(String text) { 3. text = text.replace (J. I); 4. } 5. 6. public static void buffer Replace (String Buffer text) { 7. text = text.append (c) 8. } 9. 10. public static void main (String args []) { 11. String textString = new String (java); 12. String Buffer textBuffer = new String Buffer (java); 13. 14. stringReplace (textString): 15. buffer Replace (textBuffer): 16. 17. System.out.printIn(TextString + textBuffer); 18. } 19. } What is the output? Answer: ajvajavac Question: 52 Given: 1. public class Foo {

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 19 of 100 TestKing.net

    2. public static void main (String [] args) { 3. int i = l: 4. int j = i++; 5. if ((i = = ++j) | (i++==j)) { 6. i + = j; 7. } 8. } 9. } What is the final value of i? A. 1 B. 2 C. 3 D. 4 E. 5 Answer: E Question: 53 Given: 1. public class Test { 2. public static void main (String args[]) { 3. int i + 0 x FFFFFFF1: 4. int j = i; 5. 6. } 7. } What is the decimal value of J at line 5? A. 0 B. 1 C. 14 D. 15 E. An error at line 3 cause compilation to fail. F. An error at line 4 cause compilation to fail. Answer: C Question: 54 Given: 8. int index = 1: 9. Boolean [] test = new boolcan [3]; 10. boolcan foo = test [index]; What is the result? A. foo has the value of 0. B. foo has the value of null. C. foo has the value of true. D. foo has the value of false. E. An-exception is thrown. F. The code will not compile.

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 20 of 100 TestKing.net

    Answer: D Question: 55 Given; 1. public class Test 2. public static void main (String[] args ) { 3. String foo = args [1]: 4. String bar = args [2]: 5. String bar = args [3]: 6. } 7. } And command line is vacation: Java Test red green blue A. bas has the value of . B. baz has the value of null. C. bas has the value of red. D. baz has he value of blue. E. baz has the value of green. F. the code does not compile. G. The program throws and exception. Answer: G Question: 56 Which three are valid URL mappings to a servlet in a web deployment descriptor? (Choose three.) A. */* B. /*.do C. myServlet D. /Myservlet E. /MyServlet/* F. MyServlet/*.isp Answer: B, D, E Question: 57 Given: 1. public class X { 2. public Object m () { 3. Object o = new Float ( 3.14 F); 4. Object [] oa = new Object [1]: 5. oa [0] = o; 6. o = null: 7. oa [0] = null; 8. return o: 9. } 10. } When is the Float object. Created in line 3, eligible for garbage collection?

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 21 of 100 TestKing.net

    A. just after line 5 B. just after line 6 C. just after line 7 D. just after line 8 (that is . as the method returns) Answer: C Question: 58 1. public class Test { 2. public static String output = ; 3. 4. public static void foo (int i ) { 5. try { 6. if ( i = = 1) { 7. throw new Exception (): 8. } 9. output + = 1; 10. } 11. catch (Exception e) { 12. output + = 2; 13. return; 14. } 15. finally { 16. out put + = 3; 17. { 18. output + = 4; 19. } 20. 21. public statie void main (String args [] { 22. foo (0); 23. foo (1); 24. 25. } 26. } What is the value of the variable output at line 24? Answer: 13423 Question: 59 5. public class My Tag Handler extends Tag Support { 6. publin int do Start Tag () throws Jsp Exception { 7. try{ 8. Writer out = page Context.get Response ().get Writer (); 9. String name = page Context. Find Attribute (name); 10. out.print (name); 11. } catch (Exception ex) {/* handle exception */} 12. return SKIP_BODY: 13. } 14. 15. PUBLIC INT DO after Body () throws Jsp Exception { 16. try { 17. Writer out =page Context.get Response ().get Writer ():

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 22 of 100 TestKing.net

    18. out.print (done): 19. catch (Exception ex) /* handle exception */} 21. } 42. } The attribute name has a value of Foo, What is the result if this tag handlers tag is invoked? A. Foo B. done C. Foodone D. An exception is thrown at runtime. E. Compilation fails because of an error in this code. Answer: A Question: 60 For a given Servlet Response response, which two retrieve an object for writing text data? (Choose two) A. response.get Writer () B. response.get Output Stream () C. response.get Output Writer () D. response.get Writer ().get Output Stream() E. response.get Writer (Writer.OUTPUT_TEXT) Answer: A, B Question: 61 Which retrieves all cookies sent in a given HttpSErvletRequest request? A. request.getCookies() B. request.getAttributes() C. request.getSession ().getCookies() D. request.getSession (). GetAttributes() Answer: A Question: 62 Which two are valid values for the element inside a element of a web application deployment descriptor? (Choose two.) A. NULL B. SECURE C. INTEGRAL D. ENCRYPTED E. CONFIDENTIAL Answer: C, E Explanation:

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 23 of 100 TestKing.net

    The element can contain any of three values: NONE , INTEGRAL , or CONFIDENTIAL. Question: 63 Which two statements are true? (Choose two.) A. An anonymous inner class can be declared inside of a method. B. An anonymous inner class constructor can take arguments in some situations. C. An anonymous inner class that is a direct subclass of Object can implement multiple interfaces. D. Even if a class Super does not implement any interfaces, it is still possible to define an

    anonymous inner class that is an immediate subclass of Super that implements a single interface.

    E. Even if a class Super does not implement any interfaces, it is still possible to define an anonymous inner class that is an immediate subclass of Super that implements multiple interfaces.

    Answer: A, B Question: 64 Given: 1. public class ConstOver { 2. public constOver(int x, int y, int z) { 3. } 4. } Which two overload the ConstOver Constructor? (Choose two.) A. ConstOver() {} B. protected int ConstOver(){} C. private ConstOver(int z, int y, byte x ) {} D. public Object ConstOver(Int x, int y, int z) {} E. pubic void ConstOver (byte x, byte y, byte z) {} Answer: AC Question: 65 Given: 1. public class Foo { 2. public static void main(String[] args) { 3. String Buffer a = new StringBuffer (A); 4. String Buffer b new StringBuffer (B); 5. operate (a, b); 6. System.out.printIn(a+ , + b); 7. } 8. Static void operate(StringBuffer x. String Buffer y) { 9. X.append(y); 10. y = x; 11. } 12. } What is the result? A. The code compiles and prints A,B.

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 24 of 100 TestKing.net

    B. The code compiles and prints A,A. C. The code compiles and prints B,B. D. The code compiles and prints AB,B. E. The code compiles and prints AB,AB. F. The code does not compile because + cannot be over loaded for StringBuffer. Answer: D Question: 66 Given: Integer i = new Integer (42); Long l = new Long (42); Double d = new Double (42.0); Which two expression evaluate to true? (Choose two.) A. (i = = l) B. (i = = d) C. (d = = l) D. (i.equals(d)) E. (i.equals(i)) F. (i.equals(42)) Answer: D, E Question: 67 What is the numerical range of char? A. 032767 B. 065535 C. 256255 D. 3276832767 E. Range is platform dependent. Answer: B Question: 68 Given: 1. public class Test { 2. public static void main (String [] args){ 3. String foo = args [1]; 4. String bar = args [2]; 5. String baz = args [3]; 6. System.out.printIn(baz=+baz): 7. } 8. } and the output: baz = 2 Which command line invocation will produce the output? A. java Test 2222 B. java Test 1234

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 25 of 100 TestKing.net

    C. java Test 4242 D. java Test 4321 Answer: C Question: 69 Given: 1. public interface Foo { 2. int k = 4: 3. } Which three are equivalent to line 2? (Choose three) A. final int k = 4: B. public int k = 4: C. static int k = 4: D. private int k = 4: E. abstract int k = 4: F. volatile int k = 4: G. transient int k = 4: H. protected int k = 4: Answer: A, B, C Question: 70 Given 1. public class Foo { 2. public static void main (String [] args) } 3. try { return;} 4. finally { Syste.out.printIn (Finally);} 5. } 6. } What is the result? A. The program runs and prints nothing. B. The program runs and prints Finally. C. The code comiles. But an exception is thrown at runtime. D. The code will not compile because the catch block is missing. Answer: B Question: 71 11. public class Iterate Handler extends Body Tag Support { 12. private Collection c: 13. private Iteator it: 14. public void set Coll (Collection c) {this.c + c;} 15. public int do Start Tag () throws Jsp Exception { 16. // insert code here 17. } 18. public void dolnit Body () throws Jsp Exception { 19. it = c. iterator (): 20. page Context.set Attribute (item it.next()); 21. }

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 26 of 100 TestKing.net

    22. public int do After Body () throuws Jsp Exception { 23. if (it. Has Next ()){ 24. page Context.set Attribute (item, it.next ()); 25. // insert code here 26. } else { 27. try { 28. get Body Content (). Write Out (get Previous Out ()); 29. } catch (Exception e) {} 30. // insert code here 31. } 32. } 33. } Given that the loop tag properly iterates over Collection assigned to its cool attribute. Which additions needs to be made to the Iterate Handler class for it to properly perform as the tag handler for the loop tag.? A. Insert return c. is Empty () ? EVAL_BODY_AGAIN:SKIP_BODY: at line 16

    Insert return EVAL_BODY_AGAIN: at line 25. Insert return SKIP_BODY: At line 30.

    B. Insert return c. is Empty ()? SKIP_BODY: EVAL_BODY_AGAIN: at line 16 Insert return SKIP_BODY: at line 25. Insert return EVAL_BODY_AGAIN: at line 30

    C. Insert return c. is Empty () ? EVAL_BODY_AGAIN : SKIP BODY: at line 16 Insert return EVAL_BODY_AGAIN: at line 25. Insert return SKIP_BODY: at line 30.

    D. Insert return c. is Empty ()? EVAL_BODY_AGAIN:SKIP_BODY: at line 16 Insert return SKIP_BODY: at line 25. Insert return EVAL_BODY_AGAIN: at line 30

    Answer: C Question: 72 For a given Servlet Response response, which retrieves an object for writing binary data? (Choose two) A. response.get writer () B. response.get Output Stream () C. response.getOutput Writer() D. response.get Writer ().get Output Stream () E. response.get Writer (Writer.OUTPUT_BINARY) Answer: A, B Question: 73 Which HTTP method has the characteristic that multiple indential requests may produce side effect beyond those of a single request? A. PUT B. GET C. INFO

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 27 of 100 TestKing.net

    D. POST E. HEAD F. TRACE Answer: D Question: 74 Which three are valid URL mappings to a servlet in a web deployment descriptor? (Choose three.) A. */* B. /*.do C. myServlet D. /Myservlet E. /MyServlet/* F. MyServlet/*.isp Answer: B, D, E Question: 75 Given: 1. package foo; 2. 3. public class Outer { 4. public static class Inner { 5. } 6. } Which statement is true? A. An instance of the Inner class can be constructed with new Outer.Inner(). B. An instance of the Inner class can only be constructed from within the Outer class. C. An instance of the Inner class can only be constructed from within the Outer class. D. From with in the package bar, an instance of the Inner class can be constructed with new Inner(). Answer: A Question: 76 1. class A { 2. public int getNumber(int a) { 3. return a + l; 4. } 5. } 6. 7. class B extends A { 8. public int getNumber(int a, char c) { 9. return a + 2; 10. } 11. 12. public static void main (String args[]) { 13. B b = new B(); 14. System.out.print(b.getNumber(0)); 15. }

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 28 of 100 TestKing.net

    16. } What is the result? A. Compilation succeeds and 1 is printed. B. Compilation succeeds and 2 is printed. C. An error at line 8 causes compilation to fail. D. An error at line 14 causes compilation to fail. Answer: A Question: 77 1. public class Test { 2. public static void replace J(String text) { 3. text.replace(J I); 4. } 5. 6. public static void main (String args []) { 7. String text = new String (java); 8. replace J (text); 9. System.out.printIn(text); 10. } 11. } What is the result? A. The program prints lava. B. The program prints java. C. An error at line 7 causes compilation to fail. D. Complication succeeds but the program throws an exception. Answer: B Question: 78 Given: 1. public class Foo { 2. private int val: 3. public Foo (int v) { val = v:} 4. public static void main ( String [] args ) { 5. Foo a = new Foo (10): 6. Foo b = new Foo (10): 7. Foo c = a: 8. int d = 10; 9. double e = 10.0: 10. } 11. } Which three logical expressions evaluate to true? (Choose three.) A. (a = = c) B. (d = = c) C. (b = = d) D. (a = = b) E. (b = = c)

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 29 of 100 TestKing.net

    F. (d == 10.0) Answer: A, B, F Question: 79 Which two are valid declarations of char? (Choose two.) A. Char ch = a; B. char ch = ; C. char ch = caf; D. char ch = ucafe; E. char ch = ucafe; F. char ch = u10100; G. char ch = (char) true; Answer: B, E Question: 80 Given: 1. Public class Foo { 2. static Strings; 3. public static void main (String[] args) { 4. System.out.printIn ( s= + s): 5. } 6. } What is the result? A. The code compiles and s= is printed. B. The code compiles and s=null is printed. C. The code does not compile because Strings is not initialized. D. The code does not compile because because Strings cannot be referneed. E. The code comiles.butt a NullPointerException is thrown when toString is called. Answer: B Question: 81 1. package foo; 2. 3. import java. Util. Vector; 4. 5. protected class my Vector extends Vector { 6. int i = 1; 7. public MyVector () { 8. i = 2; 9. } 10. } 11. 12. public class MyNewVector extends MyVector { 13. public MyNew Vector () { 14. I = 4; 15. } 16. public static void main (String args []) { 17. MyVector v = new MyNewVector ():

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 30 of 100 TestKing.net

    18. } 19. } What is the result? A. Compilation will succeed. B. Compilation will fail at line 5. C. Compilation will fail at line 6. D. Compilation will fail at line 14. E. Compilation will fail at line 17. Answer: B Question: 82 1. import java. Io. IO Exception: 2. public class Exception Test { 3. public static void main (String [] args){ 4. try { 5. method A () 6. catch (IOException e) { 7. System.out.printIn (Caught IO Exception) 8. catch (exception e) { 9. System. Out. printIn (Caught Exception); 10. } 11. } 12. public void method A () { 13. throw new IO Exception () ; 14. } 15. } What is the result? A. The code will not compile. B. The output is Caught Exception C. The output is Caught IO Exception D. The program executes normally without printing a message. Answer: A Question: 83 Which statement is true if the do Start Tag method returns EVAL_BODY_BUFFERED? A. The tag handler must extend body Tag. B. The do After Body method is NOT called. C. The set Body Content method is called. D. It is never legal to return EVAL_BODY_BUFFERED from do Start Tag. Answer: C Question: 84 A collection of products is stored in the Servle Context in an attribute called catalog. Which JSTL code structure iterated over each product in the collection and prints out the names of the products in an un-ordered list?

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 31 of 100 TestKing.net

    A.

    B.

    C.

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 32 of 100 TestKing.net

    Answer: D Question: 87 Which two are equivalent? (Choose two.) A. 3 / 2 B. 3 < 2 C. 3 * 4 D. 3

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 33 of 100 TestKing.net

    A. i = 6 and j = 5 B. i = 5 and j = 5 C. i = 6 and j = 4 D. i = 5 and j = 6 E. i = 6 and j = 6 Answer: A Question: 91 Given a header in an HTTP request: X-Retries:4 Which two retrieve the value of the header from a given ServletRequest request? (Choose two.) A. request.getHeader (X-Retries) B. request.getIntHeader (X-Retries) C. request.getRequestHeader (x-Retries) D. request.getHeaders (X-Retries).get (0) E. re request.getRequest Headers (X-Retries). Get (0) Answer: A, B Question: 92 Given: String value = getServletContext().GetlnitParameter(foo): in an HttpServlet and a web application deployment descriptor that contains: foo frodo Which two are true? (Choose two) A. The foo initialization parameter CANNOT be set programmatically. B. Compilation fails because getlnitParameter returns type Object. C. The foo initialization parameter is NOT a servlet initialization parameter. D. Compilation fails because ServletContext does NOT have a getlnitParameter method. E. The foo parameter must de defined within the element of the deployment descriptor. F. The foo initialization parameter can also be retrievedusing getSErvletConfig(). GetlnitParameter (foo). Answer: A, C Question: 93 Given: 1. class BaseClass { 2. private float x = 1.0 f; 3. protected float getVar() {returnx:} 4. } 5. class SubClass extends BaseClass { 6. private float x = 2.0f;

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 34 of 100 TestKing.net

    7. //insert code here 8. } Which two are valid examples of method overriding? (Choose two.) A. float getVar() {return x:} B. public float getVar() {return x; } C. public double getVar() {return x; } D. protected float getVar() {return x; } E. public float getVar(float f) {return f;} Answer: B, D Question: 94 Given: 1. public class Foo { 2. public static void main (String [] args) { 3. int i = l: 4. int j = I++; 5. if ((i>++j) && (i++ = = j)) { 6. i + = j: 7. } 8. } 9. } What is the final value of i? A. 1 B. 2 C. 3 D. 4 E. 5 Answer: B Question: 95 Given: 1. //Point X 2. public class Foo{ 3. public static void main (String[] args) throws Exception { 4. java.ioi.PrintWriter out = new java.io.PrintWriter( 5. new java.io.Output Stream Writer (System.out), true): 6. out.printIn (Hello); 7. } 8. } Which statement at Point X on line 1 allows this code to compile and run? A. import java.io.*.; B. include java.io.*; C. import java.io.PrintWriter; D. include java.io.PrintWRiter; E. No statement in needed.

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 35 of 100 TestKing.net

    Answer: E Question: 96 Given 3. Int i = 1 , j = 10: 4. do { 5. if (i++> --j ) continue: 6. } while ( i

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 36 of 100 TestKing.net

    D. float foo = 2.02f: E. float foo = 3.03d: Answer: A, D, F Question: 100 Which will declare a method that is available to all members of the same package and be referenced without an instance of the class? A. abstract public void methoda (); B. public abstract double inethoda (); C. static void methoda (double dl) {} D. public native double methoda () {} E. protected void methoda (double dl) {} Answer: C Question: 101 Given an Http Session session. A Servlet Request request. And a Servlet Context context. Which retrieves a URL to /WEB INF/ my config.xml within a web application? A. session.get Resource (/WEB-INF/myconfig.xml) B. request.get Resource (/WEB-INF/myconfig.xml) C. context.get Resource (/WEB-INF/myconfig.xml) D. get Class ().get Resource (/WEB-INF/myconfig.xml) Answer: C Question: 102 Given: 10. public void service (Http Servlet Request request, 11. Http Servlet Response response) { 12. // your code here 13. { Which code snippet inserted at line 12 cause the client to redirect to http://www.example.com? A. response.send Redirect (http://www.example.com): B. response.send Redirect (new URL (http://www.example.com)); C. Request Dispatcher rd= get Servlet Context (). Get Request Dispatcher ( http://www.example.com) rd. forward (request. Response): D. Request Dispatch rd= Get Servlet Context ().get Request Dispatcher( New URL (http://www.example.com)); Rd. forward (request.response): Answer: A Question: 103 Which statement is true?

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 37 of 100 TestKing.net

    A. The Error class is a Runtime Exception. B. No exceptions are subclasses of Error. C. Any statement that may throw an Error must be enclosed in a try block. D. any statement that may throw an Exception must be enclosed in a try block. E. Any statement that may throw an Runtime Exception must be enclosed in a try block. Answer: B Question: 104 Given: 8. int index = [; 9. String [] test = new String [3]; 10. String foo = test [index] What is the result? A. foo has the value B. foo has the value null. C. An exception is thrown. D. The code will not compile. Answer: B Question: 105 1. public class X { 2. public static void main (String [] args) { 3. Strings = new String (Hello); 4. modify (s); 5. System.out.printIn(s): 6. } 7. 8. public static void modify (String s) { 9. s + = world! 10. } 11. } What is the result? A. The program runs and prints Hello B. An error causes compilation to fail. C. The program runs and prints Hello world!. D. The program runs but aborts with an exception. Answer: A Question: 106 1. interface Foo { 2. int k = 0; 3. } 4. 5. public class Test implements Foo { 6. public static void main (String args []){ 7. int i:

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 38 of 100 TestKing.net

    8. Test test = new Test (): 9. i = test. k: 10. i = Test.k: 11. i = Foo. k: 12. } 13. } What is the result? A. Compilation succeeds. B. An error at line 2 cause compilation to fail. C. An error at line 9 cause compilation to fail. D. An error at line 10 cause compilation to fail. E. An error at line 11 cause compilation to fail. Answer: A Question: 107 Given an HttpServletRequest request, which retrieves an object of type Account with an Id of account? A. Account account = request.get Resource(account): B. Account account = request.get Attribute (account): C. Account account = request.get Parameter (account): D. Account account = (Account)request.getResource (account): E. Account account = (Account) request.get Attribute (account): F. Account account = (Account) request.get Paramter (account): Answer: E Question: 108 Which HTTP method represents a request for information about the supported methods on an HTTP server? A. GET B. INFO C. HEAD D. TRACE E. OPTIONS Answer: E Question: 109 For a given ServletResponse response, which retrieves an object for writing binary data? A. response.getWriter() B. response.getOutputStream() C. response.getOutputWriter() D. response.getWriter().getOutputSTream() E. response.getWriter(Writer.OUTPUT_BINARY) Answer: B Question: 110

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 39 of 100 TestKing.net

    A JSP page needs to instantiate a JavaBean to be used by only that page. Which two jsp:useBean attributes must be used to access this attribute in the JSP page? (Choose two.) A. id B. type C. name D. class E. scope F. create Answer: A, D Explanation: Scope is default to page, so don't need it. Only two "required" vars are ID and CLASS. Question: 111 In form-based authentication, what must be included in the HTML returned from the URL specified by the element? A. a base-64 encoded user name and password B. a form that POSTs to the j_security_check URL C. an applet that requests the user name and password from the user D. a hidden field that supplies the login-constraint used by the application Answer: B Question: 112 Which two security mechanisms protect the response stream? (Choose two.) A. authorization B. data integrity C. confidentiality D. authentication Answer: B, C Question: 113 Which two pieces of information are needed when declaring the web resource collection in the deployment descriptor? (Choose two.) A. the URL pattern that requires authorization B. the HTTP methods that require authorization C. the users allowed access to the web resource D. the J2EE roles allowed access to the web resource E. the authentication mechanism required by the web resource Answer: A, B Question: 114 When using a form-based authentication, which action must be used in the login form? A. j_login B. j_get_user

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 40 of 100 TestKing.net

    C. j_login_check D. j_get_security E. j_security_check Answer: E Question: 115 Which security mechanism is employed only on the server-side to limit access to resources or components? A. authorization B. data integrity C. confidentiality D. authentication Answer: A Question: 116 Which element of a web application deployment descriptor element is required? A. B. C. D. E. Answer: E Question: 117 Given: 1. 2. 3. 4. Today is: 5. 6. What needs to go on line 1? A. B. C. D. Answer: A Question: 118 Which three occur during JSP page translation? (Choose three.) A. The jspInit method is called. B. The JSP page implementation class is created. C. The JSP page implementation class is compiled.

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 41 of 100 TestKing.net

    D. The JSP page is validated for syntatic correctness. E. The associated tag files are validated for syntatic correctness. Answer: B, C, D Question: 119 Given the web application deployment descriptor: 10. 11. 12. *.jsp 13. false 14. 15. and example.jsp: 10 x 5 = ${10 * 5} 2 * 3 = What is the result? A. An error occurs during page translation. B. Translation is successful, but nothing is included in the response. C. Both 10 x 5 = 50 and 2 * 3 = 6 are included in the JSP response. D. The text 10 x 5 = 50 is included in the JSP response, but 2 * 3 = 6 is NOT. E. The text 2 * 3 = 6 is included in the JSP response, but 10 x 5 = 50 is NOT. Answer: C Question: 120 Given:

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 42 of 100 TestKing.net

    Which is equivalent? A. Welcome B. Welcome C. Welcome D. Welcome E. Welcome Answer: A Question: 122 The JSP developer wants a comment to be visible in the final output to the browser. Which comment style needs to be used in a JSP page? A. B. C. D. Answer: A Question: 123 Which EL expression evaluates to the request URI? A. ${requestURI} B. ${request.URI} C. ${request.getURI} D. ${request.requestURI} E. ${requestScope.requestURI} F. ${pageContext.request.requestURI} G. ${requestScope.request.request.URI} Answer: F Explanation: The request's URI (obtained from > HttpServletRequest): ${pageContext.request.requestURI} Question: 124 Given: 1. 3. ${5 + 3 lt 6} 4. ${requestScope[foo][0] ne 10 div 0} 5. ${10 div 0} What is the result? A. true true B. false true C. false true 0 D. true true Infinity E. false true Infinity

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 43 of 100 TestKing.net

    F. An exception is thrown. G. Compilation or translation fails Answer: E Question: 125 Given an EL function foo, in namespace func, that requires a long as a parameter and returns a Map, which two are valid invocations of function foo? (Choose two.) A. ${func(1)} B. ${foo:func(4)} C. ${func:foo(2)} D. ${foo(5):func} E. ${func:foo(easy)} F. ${func:foo(3).name} Answer: C, F Question: 126 A web application allows the HTML title banner to be set using a servlet context initialization parameter called titleStr. Which two properly set the title in this scenario? (Choose two.) A. ${titleStr} B. ${initParam.titleStr} C. ${params[0].titleStr} D. ${paramValues.titleStr} E. ${initParam[titleStr]} F. ${servletParams.titleStr} G. ${request.get(titleStr)} Answer: B, E Question: 127 Given: 11. 16. Which three EL expressions, inserted at line 16, are valid and evaluate to d? (Choose three.) A. ${map.c} B. ${map[c]} C. ${map[c]} D. ${map.map.b} E. ${map[map.b]} F. ${map.map(map.b)} Answer: A, C, E

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 44 of 100 TestKing.net

    Question: 128 Within a web application deployment descriptor, which maps the com.example.LoginServlet servlet to /utils/LoginServlet? A. com.example.LoginServlet /utils/LoginServlet B. com.example.LoginServlet /utils/LoginServlet C. com.example.LoginServlet Login Servlet /utils/LoginServlet D. Login.Servlet com.example.LoginServlet Login.Servlet /utils/LoginServlet Answer: D Question: 129 Which element, defined as a child of a element in the web application deployment descriptor, guarantees a servlet will be initialized at the time the application is deployed? A. B. 1 C. -1 D. true Answer: B Question: 130 Which path is required to be present within a WAR file? A. /classes B. /index.html C. /MANIFEST-INF D. /WEB-INF/web.xml E. /WEB-INF/classes F. /WEB-INF/index.html G. /META-INF/index.xml Answer: E

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 45 of 100 TestKing.net

    Question: 131 In which two web application directories can dependent classes and libraries be located? (Choose two.) A. /WEB-INF/lib as a JAR file B. /META-INF/lib as a JAR file C. /classes as compiled class files D. /WEB-INF/lib as compiled class files E. /WEB-INF/classes as compiled class files F. /META-INF/classes as compiled class files Answer: A, E Question: 132 A web component accesses a local EJB session bean with a component interface of com.example.Account with a home interface of com.example.AccountHome and a JNDI reference of ejb/Account. Which makes the local EJB component accessible to the web components in the web application deployment descriptor? A. ejb/Account Session com.exampleAccountHome com.example.Account B. ejb/Account Session com.example.AccountHome com.example.Account C. ejb/Account Session com.example.AccountHome com.example.Account D. ejb/Account Session com.example.AccountHome com.example.Account Answer: C Reference: http://www.redhat.com/docs/manuals/rhaps/jonas-guide/ch-beans-ejbref.html Question: 133 Which makes the local EJB component accessible to the web components in the web application deployment descriptor?

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 46 of 100 TestKing.net

    A. ejb/Account Session com.example.AccountHome com.example.Account B. ejb/Account Session com.example.AccoutHome com.example.Account C. ejb/Account Session com.example.AccountHome com.example.Account D. ejb/Account Session com.example.AccountHome com.example.Account Answer: C Question: 134 Which three are described in the standard web application deployment descriptor? (Choose three.) A. session configuration B. MIME type mappings C. context root for the application D. servlet instance pool configuration E. web container default port bindings F. ServletContext initialization parameters Answer: A, B, F Question: 135 Which defines the welcome files in a web application deployment descriptor? A. /welcome.jps /index.html B. welcome.jsp index.html

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 47 of 100 TestKing.net

    C. welcome.jsp index.html D. /welcome.jsp /index.html E. Welcome welcome.jsp Index index.html Answer: B Question: 136 In which two locations can library dependencies be defined for a web application? (Choose two.) A. the web application deployment descriptor B. the /META-INF/dependencies.xml file C. the /META-INF/MANIFEST.MF manifest file D. the /META-INF/MANIFEST.MF manifest of a JAR in the web application classpath Answer: C, D Question: 137 A RequestDispatcher can be obtained from which two objects? (Choose two.) A. ServletConfig B. ServletContext C. HttpServletRequest D. HttpServletResponse Answer: B, C Question: 138 A developer chooses to avoid using SingleThreadModel but wants to ensure that data is updated in a thread-safe manner. Which two can support this design goal? (Choose two.) A. Store the data in a vocal variable. B. Store the data in an instance variable. C. Store the data in the HttpSession object. D. Store the data in the ServletContext object. E. Store the data in the ServletRequest object.

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 48 of 100 TestKing.net

    Answer: A, E Question: 139 For which three events can web application event listeners be registered? (Choose three.) A. when a session is created B. after a servlet is destroyed C. when a session has timed out D. when a cookie has been created E. when a servlet has forwarded a request F. when a session attribute value is changed Answer: A, C, F Question: 140 Servlet A receives a request that it forwards to servlet B within another web application in the same web container. Servlet A needs to share data with servlet B and that data must not be visible to other servlets in As web application. In which object can the data that A shares with B be stored? A. HttpSession B. ServletConfig C. ServletContext D. HttpServletRequest E. HttpServletResponse Answer: D Question: 141 Which three are true about the HttpServletRequestWrapper class? (Choose three.) A. The HttpServletRequestWrapper is an example of the Decorator pattern. B. The HttpServletRequestWrapper can be used to extend the functionally of a servlet request. C. A subclass of HttpServletRequestWrapper CANNOT modify the behavior of the getReader

    method. D. An HttpServletRequestWrapper may be used only by a class implementing the

    javax.servlet.Filter interface. E. An HttpServletRequestWrapper CANNOT be used on the request passed to the

    RequestDispatcher.include method. F. An HttpServletRequestWrapper may modify the header of a request within an object

    implementing the javax.servlet.Filter interface. Answer: A, B, D Explanation: B: It is adding features to the request. Question: 142 Which is the correct web application deployment descriptor element for defining a servlet initialization parameter? A. timeout 1000

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 49 of 100 TestKing.net

    B. timeout 1000 C. timeout 1000 D. timeout 1000 Answer: A Question: 143 A developer is designing a multi-tier web application and discovers a need to log each incoming client request. Which two patterns, taken independently, provide a solution for this problem? (Choose two.) A. Transfer Object B. Service Locator C. Front Controller D. Intercepting Filter E. Business Delegate F. Model-View-Controller Answer: C Question: 144 A developer is designing a web application that makes many fine-grained remote data requests for each client request. During testing, the developer discovers that the volume of remote requests significantly degrades performance of the application. Which design pattern provides a solution for this problem? A. Flyweight B. Transfer Object C. Service Locator D. Dispatcher View E. Business Delegate F. Model-View-Controller Answer: B Question: 145 Squeaky Beans Inc. hired an outside consultant to develop their web application. To finish the job quickly, the consultant created several dozen JSP pages that directly communicate with the database. The Squeaky business team has since purchased a set of business objects to model their system, and the Squeaky developer charged with maintaining the web application must now refactor all the JSPs to work with the new system. Which pattern can the developer use to solve this problem?

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 50 of 100 TestKing.net

    A. Transfer Object B. Service Locator C. Intercepting Filter D. Business Delegate Answer: D Question: 146 A developer is designing a multi-tier application and discovers a need to hide the details of establishing and maintaining remote communications from the client. In addition, the application needs to find, in a transparent manner, the heterogeneous business components used to service the clients requests. Which design patterns, working together, address these issues? A. Business Delegate and Transfer Object B. Business Delegate and Service Locator C. Front Controller and Business Delegate D. Intercepting Filter and Transfer Object E. Model-View-Controller and Intercepting Filter Answer: B Question: 147 A developer is designing a web application that must support multiple interfaces, including: an XML web service for B2B HTML for web-based clients WML for wireless customers Which design pattern provides a solution for this problem? A. Session Faade B. Business Delegate C. Data Access Object D. Model-View-Controller E. Chain of Responsibility Answer: D Question: 148 Which two are characteristics of the Transfer Object design pattern? (Choose two.) A. It reduces network traffic by collapsing multiple remote requests into one. B. It increases the complexity of the remote interface by removing coarse-gained methods. C. It increases the complexity of the design due to remote synchronization and version control

    issues. D. It increases network performance introducing multiple fine-grained remote requests which

    return very small amounts of data. Answer: A, C Reference: http://java.sun.com/blueprints/corej2eepatterns/Patterns/TransferObject.html

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 51 of 100 TestKing.net

    Explanation: A: Search page for "Reduces Network Traffic C: Search page for "May Increase Complexity due to Synchronization and Version Control. Question: 149 The Squeaky Beans Inc. shopping application was initially developed for a non-distributed environment. The company recently purchased the Acme Application Server, which supports distributed HttpSession objects. When deploying the application to the server, the deployer marks it as distributable in the web application deployment descriptor to take advantage of this feature. Given this scenario, which two must be true? (Choose two.) A. The J2EE web container must support migration of objects that implement Serializable. B. The J2EE web container must use the native JVM Serialization mechanism for distributing

    HttpSession objects. C. As per the specification, the J2EE web container ensures that distributed HttpSession objects

    will be stored in a database. D. Storing references to Enterprise JavaBeans components in the HttpSession object might

    NOT be supported by J2EE web containers. Answer: A, D Explanation: A: Implement the java.io.Serializable interface when developing new objects to be stored in the HTTP session. Reference: http://publib.boulder.ibm.com/infocenter/wasinfo/v5r1//index.jsp?topic=/com.ibm.websphere.base.doc/info/aes/ae/rprs_ Question: 150 Which three are valid values for the body-content attribute of a tag directive in a tag file? (Choose three.) A. EL B. JSP C. empty D. dynamic E. scriptless F. tagdependent Answer: C, E, F Question: 151 Given: 3. public class MyTagHandler extends TagSupport { 4. public int doStartTag() { 5. // insert code here 6. // return an int 7. } 8. // more code here

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 52 of 100 TestKing.net

    18. } There is a single attribute foo in the session scope. Which three code fragments, inserted independently at line 5, return the value of the attributes? (Choose three.) A. Object o = pageContext.getAttribute(foo); B. Object o = pageContext.findAttribute(foo); C. Object o = pageContext.getAttribute(foo, PageContext.SESSION_SCOPE); D. HttpSession s = pageContext.getSession(); Object o = s.getAttribute(foo) E. HttpServletRequest r = pageContext.getRequest(); Object o = r.getAttribute(foo); Answer: Pending. Send your suggestions at [email protected] Question: 152 The tl:taskList and tl:task tags output a set of tasks to the response and are used as follows: 11. 12. 13. 14. 15. The tl:task tag supplies information about a single task while the tl:taskList tag does the final output. The tag handler for tl:taskList is TaskListTag. The tag handler for tl:task is TaskTag. Both tag handlers extend BodyTagSupport. Which allows the tl:taskList tag to get the task names from its nested tl:task children? A. It is impossible for a tag handler that extends BodyTagSupport to communicate with its parent and child tags. B. In the TaskListTag.doStartTag method, call super.getChildTags() and iterate through the results. Cast each result to a TaskTag and call getName(). C. In the TaskListTag.doStartTag method, call getChildTags() on the PageContext and iterate through the results. Cast each result to a TaskTag and call getName(). D. Create an addTaskName method in TaskListTag. Have the TaskListTag.doStartTag method, return BodyTag.EVAL_BODY_BUFFERED. In the TaskTag.doStartTag method, call super.getParent(), cast it to a TaskListTag, and call addTaskName(). E. Create an addTaskName method in TaskListTag. Have the TaskListTag.doStartTag method, return Body.Tag.EVAL_BODY_BUFFERED. In the TaskTag.doStartTag method, call findAncestorWithClass() on the PageContext, passing TaskListTag as the class to find. Cast the result to TaskListTag and call addTaskName(). Answer: D Question: 153 Which interface must a class implement so that instances of the class are notified after any object is added to a session? A. javax.servlet.http.HttpSessionListener B. javax.servlet.http.HttpSessionValueListener

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 53 of 100 TestKing.net

    C. javax.servlet.http.HttpSessionBindingListener D. javax.servlet.http.HttpSessionAttributeListener Answer: C Question: 154 Assume the custom tag my:errorProne always throws a java.lang.RuntimeException with the message "File not found". An error page has been configured for this JSP page. Which option prevents the exception thrown by my:errorProne from invoking the error page mechanism and outputs the message "File not found" in the response? A. ${ex.message} B. ${ex.message} C. ${ex.message} D. ${ex.message} E. ${ex.message} Answer: B Question: 155 Given that a scoped attribute cart exists only in a user's session, which two, taken independently, ensure the scoped attribute cart no longer exists? (Choose two.) A. ${cart = null} B. C. D. E. cart F. G. ${cart} Answer: D, E Incorrect Answers:

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 54 of 100 TestKing.net

    Not C: no session scope attribute Not G: ${cart} will return the VALUE of cart, not the cart variable Question: 156 Given an HttpServletRequest request and an HttpServletResponse response: 41. HttpSession session = null; 42. // insert code here 43. if(session == null) { 44. // do something if session does not exist 45. } else { 46. // do something if session exists 47. } To implement the design intent, which statement must be inserted at line 42? A. session = response.getSession(); B. session = request.getSession(); C. session = request.getSession(true); D. session = request.getSession(false); E. session = request.getSession(jsessionid); Answer: D Question: 157 Given in a single JSP page: Which two are true? (Choose two.) A. The prefix java is reserved. B. The URI myTags must be properly mapped to a TLD file by the web container. C. A translation error occurs because the prefix is considered identical by the web container. D. For the tag usage , the tag1 must be unique in the union of tag names in myTags and moreTags. Answer: A, B Question: 158 Which two are true about the JSTL core iteration custom tags? (Choose two.) A. It may iterate over arrays, collections, maps and strings. B. The body of the tag may contain EL code, but not scripting code. C. When looping over collections, a loop status object may be used in the tag body. D. It may iterate over a map, but only the key of the mapping may be used in the tag body. E. When looping over integers (for example begin1='1' end='10'), a loop status object may not be used in the tag body. Answer: A, C Explanation: B is incorrect, they have an example of using a status object while doing a "begin/end" pair.

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 55 of 100 TestKing.net

    Search for: "if you use the attribute begin="10", then for the first loop where enters its body, index will equal 10." Reference: http://java.sun.com/developer/Books/javaprogramming/jstl/jstl_chap05.pdf Question: 159 A web application contains a tag file called beta.tag in/WEB-INF/tags/alpha. A JSP page called sort.jsp exists in the web application and contains only this JSP code: 1. 3. The sort.jsp page is requested. Which two are true? (Choose two.) A. Tag files can only be accessed using a tagdir attribute. B. The sort.jsp page translates successfully and invokes the tag defined by beta.tag. C. The sort.jsp page produces a translation error because a taglib directive must always have a

    uri attribute. D. Tag files can only be placed in /WEB-INF/tags, and NOT in any subdirectories of /WEB-

    INF/tags. E. The tagdir attribute in line 2 can be replaced by a uri attribute if a TLD referring to beta.tag is

    created and added to the web application. Answer: B, E Explanation: http://java.boot.by/wcd-guide/ch09.html D is incorrect, the tagdir directive includes subdirectories also. Also confirmed here, on Sun's spec: http://java.sun.com/products/jsp/syntax/2.0/syntaxref2012.html Question: 160 Which statement is true about web container session management? A. Access to session-scoped attributes is guaranteed to be thread-safe by the web container. B. To activate URL rewriting, the developer must use the HttpServletResponse.setURLRewriting method. C. If the web application uses HTTPS, then the web container may use the data on the HTTPS request stream to identify the client. D. The JSESSIONID cookie is stored permanently on the client so that a user may return to the web application and the web container will rejoin that session. Answer: C Question: 161 Given the service method of an HttpServlet: 12. public void service(HttpServletRequest request, 13. HttpServletResponse response) 14. throws ServletException, IOException { 15. HttpSession session = request.getSession();

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 56 of 100 TestKing.net

    16. // insert code here 17. } Which statement, inserted at line 16, unbinds an attribute from a session? A. session.unbind(key); B. session.remove(key); C. session.removeAttribute(key); D. session.unbindAttribute(key); E. session.deleteAttribute(key); Answer: C Question: 162 Given the definition of MyServlet: 11. public class MyServlet extends HttpServlet { 12. public void service(HttpServletRequest request, 13. HttpServletResponse response) 14. throws ServletException, IOException { 15. HttpSession session = request.getSession() 16. session.setAttribute(myAttribute, myAttributeValue); 17. session.invalidate(); 18. response.getWriter().println(value= + 19. session.getAttribute(myAttribute)); 20. } 21. } What is the result when a request is sent to MyServlet? A. An IllegalStateException is thrown at runtime. B. An InvalidSessionException is thrown at runtime. C. The string value=null appears in the response stream. D. The string value=myAttributeValue appears in the response stream. Answer: A Question: 163 Which method must be used to encode a URL passed as an argument to HttpServletResponse.sendRedirect when using URL rewriting for session tracking? A. ServletResponse.encodeURL B. HttpServletResponse.encodeURL C. ServletResponse.encodeRedirectURL D. HttpServletResponse.encodeRedirectURL Answer: D Question: 164 Exhibit

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 57 of 100 TestKing.net

    A servlet sets a sessions-scoped attribute product with an instance of com.example.Product and forwards to a JSP. Which two output the name of the product in response? (Choose two.) A. ${product.name} B. C. D. E. Answer: A, B

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 58 of 100 TestKing.net

    Question: 165 Given: 1. 2. 3. Which EL expression, inserted at line 3 is valid and evaluated to beanValue? A. ${bean} B. ${value} C. ${beanValue} D. ${com.example.bean} E. ${requestScope[com.example.bean]} F. ${request.get(com.example.bean).toString()} Answer: E Question: 166 Given: 2. Which two successfully translate and result in a value of true? (Choose two.) A. ${true or false} B. ${requestScope[foo][0] > 500} C. ${requestScope[foo][1] = 420} D. ${(requestScope[foo][0] lt 50) && (3 gt 2) Answer: A, D Question: 167 A JSP page needs to perform some operations before servicing the first request. Where can this be done? A. within a method called jspInit B. within the page directive of the JSP page C. within a scriptlet at the top of the JSP page D. within the XML element Answer: A Question: 168 Given the element from the web application deployment descriptor: /main>page1.jsp true and given that /main/page1.jsp contains: ${5*10} What is the result?

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 59 of 100 TestKing.net

    A. B. 50 C. ${5*10} D. The JSP fails to execute Answer: C Question: 169 Place the code snippets in the proper order to construct the JSP code to import static content into a JSP page at translation-time.

    Answer:

    Question: 170 Place the JSP elements on the appropriate tag descriptions.

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 60 of 100 TestKing.net

    Answer:

    Question: 171 Place the implicit variable on its corresponding type.

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 61 of 100 TestKing.net

    Answer:

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 62 of 100 TestKing.net

    Question: 172 Given: 1. 2. EL Tutorial 3. Example 1 4. 5. Dear ${my:nickname(user)} 6. Which, inserted at line 1, ensures that line 5 is included verbatim in the JSP output? A. B. C. D. E. Answer: C Question: 173 Given the request from mybox.Company.com, with an IP address of 10.0.1.11 on port 33086, place the appropriate ServletRequest methods onto their corresponding return values.

    Answer:

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 63 of 100 TestKing.net

    Question: 174 For a given Servletresponse response, which two retrieve an object for writing text data? (Choose two.) A. response.getWriter( ) B. response.getOutputStream( ) C. response.getOutputWriter( ) D. response.getWriter( ) .getOutputStream( ) E. response.getWriter(Writer.OUTPUT_TEXT( ) Answer: A, B Question: 175 Exhibit, Part #1

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 64 of 100 TestKing.net

    Exhibit, Part #2

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 65 of 100 TestKing.net

    Exhibit, Part #3

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 66 of 100 TestKing.net

    Given the web application deployment descriptor elements: 11. 12. ParamAdder 13. com.example.ParamAdder 14. 31. 32. ParamAdder 33. Destination 34. 55. 56. Destination 57. /dest/Destination 58. What is the result of a client request of the Source servlet with no query string? A. The output filterAdded = null is written to the response stream. B. The output filterAdded = addedByFilter is written to the response stream. C. An exception is thrown at runtime within the service method of the Source servlet. D. An exeption is thrown at runtime within the service method of the Destination servlet. Answer: A Question: 176 Place the XML elements in the web application deployment descriptor solution to configure a servlet context event listener named com.example.MyListener.

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 67 of 100 TestKing.net

    Answer:

    Question: 177 Exhibit

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 68 of 100 TestKing.net

    The resource requested by the RequestDispatcher is available and implement by the DestinationServlet. What is the result? A. An exception is thrown at runtime by SourceServlet. B. An exception is thrown at runtime by DestinationServlet. C. Only hello from dest appears in the response output stream. D. Both hello from source and hello from dest appear in the response output stream. Answer: A Question: 178 Given the web application deployment descriptor element: foo sushi Which retrieves the value associated with foo from within an HttpServlet? A. String value = getServletConfig( ).getParameter(foo); B. String value = getServletContext( ).getAttribute(foo); C. Object value = getServletContext( ).getInitParameter(foo); D. String value = getServletContext( ).getInitParameter(foo); Answer: D

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 69 of 100 TestKing.net

    Question: 179 Which element is the parent of the tag in the web application deployment descriptor? A. B. C. D. Answer: A Question: 180 Which HttpSession method stores an object in a session? A. put(String name. Object value) B. set(String name. Object value) C. setAttribute(String name. Object value) D. putAttribute(String name. Object value) E. addAttribute(String name. Object value) Answer: C Question: 181 A Company.com developer chooses to avoid using SingleThreadModel but wants to ensure that data is updated in a thread-safe manner. Which two can support this design goal? (Choose two.) A. Store the data in a local variable. B. Store the data in an instance variable. C. Store the data in the HttpSession object. D. Store the data in the ServletContext object. E. Store the data in the ServletRequest object. Answer: A, E Question: 182 A Company.com developer is designing the presentation tier for a web application that relies on a complex session bean. The session bean is still being developed and the APIs for are NOT finalized. Any changes to the session bean API directly impacts the development of the presentation tier. Which design pattern provides a means to manage the uncertainty in the API? A. View Helper B. Front Controller C. Composite View D. Intercepting Filter E. Business Delegate F. Chain of Responsibility Answer: E Question: 183 A Company.com developer is designing a multi-tier web application and discovers a need to hide the details of establishing and maintaining remote communications from the client. In addition,

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 70 of 100 TestKing.net

    because the business and resource tiers are distributed, the application needs to minimize the inter-tier network traffic related to servicing client requests. Which design patterns, working together, address these issues? A. Front Controller and Transfer Object B. Front Controller and Service Locator C. Business Delegate and Transfer Object D. Business delegate and Intercepting Filter E. Model-View-Controller and Intercepting Filter Answer: C Question: 184 Company.com has decided to use the FUBAR Application Server to host their web application. Unfortunately, the FUBAR Application Server uses the server machines file system for its JNDI namespace. Every JNDI lookup performed in the web application is translated into a file 1/0 operation, which results in very poor performance. Which J2EE pattern can help with this performance issue? A. Transfer Object B. Service Locator C. Intercepting Filter D. Model-View-Controller Answer: B Question: 185 Which is characteristic of the Business Delegate pattern? A. It decreases complexity by removing a layer of proxy classes. B. It reduces coupling between tiers by hiding implementation details. C. It decreases performance due to the lack of caching of remote data. D. It forces business-tier expectations to be dealt with in the presentation-tier. Answer: B Question: 186 A Company.com developer has created a web application that includes a servlet for each use case in the application. These servlets have become rather difficult to maintain because the request processing methods have become very large. There is also common processing code in many servlets because these use cases are very similar. Which two design patterns can be used together to refactor and simplify this web application? (Choose two.) A. Proxy B. View Helper C. Front Controller D. Session Faade E. Business Delegate F. Model-View-Controller Answer: C, F Question: 187

  • Exam Name: Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4

    Exam Type: SUN Exam Code: 310-081 Total Questions: 254

    Page 71 of 100 TestKing.net

    Which security mechanism can be directed through the element in a web deployment descriptor? A. authorization B. data integrity C. confidentiality D. authentication Answer: D Question: 188 When adding a element to a web application deployment descriptor, the inclusion of which sub-element requires the definition of an error page? A. B. C. D. E. Answer: D Question: 189 Which basic authentication type is optional for a J2EE 1.4 compliant web container? A. HTTP Basic Authentication B. Form Based Authentication C. HTTP Digest Authentication D. HTTPS Client Authentication Answer: C Question: 190 Which security mechanism uses the concept of a realm? A. authorization B. data integrity C. confidentiality D. authentication Answer: D Question: 191 Exhibit

  • Exam Name: Sun Certified Web Component Developer for the