test paper solved

31

Upload: geetha-varadharajan

Post on 02-Mar-2015

960 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Test Paper Solved
Page 2: Test Paper Solved
Page 3: Test Paper Solved
Page 4: Test Paper Solved
Page 5: Test Paper Solved
Page 6: Test Paper Solved
Page 7: Test Paper Solved
Page 8: Test Paper Solved

Topic : GF_JAVA_JAN10   Sub Topic : Classes and Objects Question 1 3 Topic : JAVA, Sub-Topic : Classes and Objects

Consider the following code:

public class Know {

Page 9: Test Paper Solved

public static void main(String[] args) { String string = "Accenture"; Object object = string; if (object.equals(string)){ System.out.print("1"); } else { System.out.print("2"); } if (string.equals(object)){ System.out.print("3"); } else { System.out.print("4"); } } } What will be the output of above code?Choose the correct option.

a. 23

b. 13

c. 24

d. 14

B

Topic : GF_JAVA_JAN10   Sub Topic : Classes and Objects Question 2 Topic:Java,Sub-Topic: Fundamentals

Consider the following code:

public class Morning { static String value = "testify"; static int value1=25; static { value1=50; System.out.println(value); System.out.println(value1); } public static void main(String[] args) { } { System.out.println(value); } }

What will be the output of the above code? Choose most appropriate option.

a. testify 50

b. testify 25

c. testify

d. Program compiles successfully but nothing is displayed on the console

A

Page 10: Test Paper Solved

Topic : GF_JAVA_JAN10   Sub Topic : Assertions Question 3 Topic:Java,Sub-Topic:Assertions

Which of the following assert statements are VALID ?

Choose appropriate option.

a. Assertions can be used to validate pre-conditions before entering a section of code.

b. Assertions can be used to validate post-conditions after executing a section of code.

c. Assertions can be used to validate class invariants whenever the state of the object is modified.

d. All of the above

D

Topic : GF_JAVA_JAN10   Sub Topic : Advanced Features Question 4 Topic:Java,Sub-Topic:Annotations

"Annotations can be used to generate repetitive boiler plate code so that the programmer can just focus on the business logic."

State TRUE or FALSE.

a. TRUE

b. FALSE

A

Topic : GF_JAVA_JAN10   Sub Topic : Advanced Features Question 5 Topic:Java,Sub-Topic:Advanced Features

Consider the below statements:

List<String> ls=new ArrayList<String>(); // Line 1

List<Object>lo=ls; //Line 2

Which line fails to compile?

Page 11: Test Paper Solved

Choose appropriate option.

a. Line 1 compiles successfully but Line 2 fails.

b. Line 2 compiles successfully but Line 1 fails.

c. Both the statements compiles successfully.

A

Topic : GF_JAVA_JAN10   Sub Topic : Collection API Question 6 Topic: JAVA, Sub-topic : Collection API

Consider the following code:

import java.util.HashSet; import java.util.Set; public class SetLoc { public static void main(String[] args) { Set locSet = new HashSet(); System.out.println(locSet.add("BDC6")); System.out.println(locSet.add("BDC4")); System.out.println(locSet.add("BDC4")); System.out.println(locSet.add("BDC3")); System.out.println(locSet.add("BDC6")); } }

What will be the output of the above code? Choose most appropriate option.

a. true true false true false

b. true true true true true

c. true false true true false

d. false false true false true

A

Topic : GF_JAVA_JAN10   Sub Topic : Servlets Question 7 Topic:J2EE,Sub-Topic:Servlet

Consider the below code:

public class exservlet extends HttpServlet { public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html");

Page 12: Test Paper Solved

int basic=Integer.parseInt(request.getParameter("basic")); int hra=basic*0.3; int da=basic*0.6; int gross=basic+hra+da; PrintWriter out=response.getWriter(); out.println("<html><body>"); out.println("HRA = :"+hra); out.println("DA = :"+da); out.println("Gross= :"+gross); out.println(" </body></html>"); } }

What will be the values of HRA,DA and Gross, if basic is: 4800?

Assume that all the files required for the above code are imported.

Choose most appropriate option.

a. HRA = 1440, DA = 2880 and Gross = 9120

b. HRA = 1430, DA = 2980 and Gross = 9120

c. HRA = 1420, DA = 2890 and Gross = 9120

d. HRA = 1440, DA = 2880 and Gross = 9110

ATopic : GF_JAVA_JAN10   Sub Topic : Classes and Objects Question 8 Topic: Java, Sub-Topic: Classes and Objects

Consider the following code: class RoomArea { float length; float breadth; void getdata(float a,float b) { length=a; breadth=b; } } class Multiple { public static void main(String args[]) { float area; RoomArea room=new RoomArea(); room.getdata(15,5); area=room.length*room.breadth; System.out.println("Area="+area); } } What will be the output of above code? Choose most appropriate option.

a. Area=15

Page 13: Test Paper Solved

b. Area=75.0

c. Area=5

B

Topic : GF_JAVA_JAN10   Sub Topic : MultiThreading Question 9 2 Topic: JAVA, Sub-Topic: MultiThreading

Refer to the code given in the attached figure. What will be the output of the code?

Choose most appropriate option.

a. Column-1:0 Column-2:0 Column-1:1 Column-2:1

b. Column-1:0 Column-1:0 Column-2:1 Column-2:1

c. Column-1:0 Column-1:1 Column-2:0 Column-2:1

d. Column-1:0 Column-2:1 Column-2:0 Column-1:1

No code

Topic : GF_JAVA_JAN10   Sub Topic : Servlets Question 10 2 Topic: JAVA, Sub-Topic: Servlets

Cookies are present in the _____ part of the HttpRequest object.

Fill in the blank with an appropriate option.

a. body

b. header

c. title

d. footer

B

Topic : GF_JAVA_JAN10   Sub Topic : Networking Question 11 2 Topic: JAVA, Sub-Topic: Networking

Which of the following class represents the IPaddress that is used by TCP and UDP protocols?

Choose most appropriate option.

Page 14: Test Paper Solved

a. InetAddress class

b. IPAddress class

c. NetAddress class

d. InternetAddress class

e. Protocol class

ATopic : GF_JAVA_JAN10   Sub Topic : Inheritance Question 12 3. Topic:Java.Sub-Topic:Fundamentals

Consider the following code:

class SuperA { SuperA() { System.out.print("Base"); } } class SuperB extends SuperA{ SuperB() { System.out.print("Base"); } } public class BasePrint extends SuperB { public static void main(String[] args) { new BasePrint(); new SuperB(); } }

How many times Base gets printed if the above code is executed? Choose appropriate option.

a. 0

b. 1

c. 2

d. 3

e. 4

ETopic : GF_JAVA_JAN10   Sub Topic : Java Fundamentals Question 13 3. Topic: Java, Sub-Topic: Fundamentals

Consider the following code:

Page 15: Test Paper Solved

public class Abroad { public static void main(String[] args) { int varA = 0; addTwo(varA++); System.out.println(varA); } static void addTwo(int varA) { varA += 3;} } What will be the output of above code? Choose appropriate option.

a. 1

b. 2

c. 3

d. 0

A

Topic : GF_JAVA_JAN10   Sub Topic : Polymorphism Question 14 3. Topic: Java, Sub-Topic: Polymorphism:

Consider the following code:

class Six_Abs { public void john() { System.out.println("Dhoom");} } public class Abs extends Six_Abs { public void john() { System.out.println("Dhoom-2"); } public static void main(String[] args) { Abs a = new Abs(); a.john(); } } What will be the output of the above code? Choose appropriate option.

a. Dhoom-2

b. Dhoom

c. Program compiles successfully but no output.

A

Page 16: Test Paper Solved

Topic : GF_JAVA_JAN10   Sub Topic : Servlets Question 15 2: Topic: JAVA, Sub-Topic: Servlets

The browser returns cookies to the servlet by adding _____ fields to HTTP.

Fill in the blank with an appropriate option.

a. Option 1: request headers

b. Option 2: response headers

c. Both Option 1 and Option 2

A

Topic : GF_JAVA_JAN10   Sub Topic : Servlets Question 16 2: Topic: JAVA, Sub-Topic: Servlets

Identify the class/interface that belongs to javax.servlet.http ?

Choose three appropriate options.

a. PrintWriter

b. HttpSession

c. HttpSessionContext

d. Cookie

Bcd

T0opic : GF_JAVA_JAN10   Sub Topic : Java Fundamentals Question 17 3 Topic : JAVA, Sub-Topic : Java Fundamentals

Consider the following code: public class Know { public static void main(String[] args) { String string = "Accenture"; Object object = string; if (object.equals(string)) { System.out.print("1"); } else { System.out.print("2"); } if (string.equals(object)) { System.out.print("3"); }

Page 17: Test Paper Solved

else { System.out.print("4"); } } }

What will be the output of above code? Choose the correct option.

a. 23

b. 13

c. 24

d. 14

B

Topic : GF_JAVA_JAN10   Sub Topic : ExceptionHandling Question 18 3 Topic : JAVA, Sub-Topic : ExceptionHandling

Consider the following code: public class Transport { public static void main(String args[]) { System.out.print("From Bang-6"); try{ new Transport(); } catch(Throwable t) { System.out.println("Transport class"); } System.out.println(" to Bang-4"); } }

What will be the output of the above code? Choose most appropriate option.

a. From Bang-6

b. to Bang-4

c. Transport class

d. From Bang-6 to Bang-4

D

Topic : GF_JAVA_JAN10   Sub Topic : JDBC Question 19 3 Topic : JAVA, Sub-Topic : JDBC

Which of the following option is used to execute SQL query multiple times?

Choose most appropriate option.

Page 18: Test Paper Solved

a. statement

b. createStatement

c. preparedStatement

d. callableStatement

cTopic : GF_JAVA_JAN10   Sub Topic : JDBC Question 20 3 Topic : JAVA, Sub-Topic : JDBC

Which of the following statements are true about the JDBC-ODBC bridge driver (Type-1) ?

Choose three appropriate options.

a. Type-1 driver is a bridge driver.

b. This type of driver enables a client to connect to an ODBC database via Java calls and JDBC.

c. Both the database and middle tier need to be java complaint.

d. ODBC binary code must be installed on each client machine that uses this driver.

ABD

Topic : GF_JAVA_JAN10   Sub Topic : JDBC Question 21 3 Topic : JAVA, Sub-Topic : JDBC

Arrange the below statements in a correct order to establish a connection to a database. 1. Loading the driver 2. Process the results 3. Making the connection with the database 4. Executing the SQL statements 5. Closing the connection.

Choose the most appropriate option.

a. 1,2,3,4,5

b. 1,3,4,2,5

c. 1,4,2,3,5

d. 4,1,2,3,5

B

Page 19: Test Paper Solved

Topic : GF_JAVA_JAN10   Sub Topic : Servlets Question 22 3 Topic : JAVA, Sub-Topic : Servlets

HttpServlet supports HTTP while the GenericServlet is protocol independent.

State TRUE/FALSE.

a. TRUE

b. FALSE

A

Topic : GF_JAVA_JAN10   Sub Topic : Servlets Question 23 3 Topic : JAVA, Sub-Topic : Servlets

URL-rewriting is a way of maintaining session between a Http Client and the servlet container which does not use cookies.

State True of False.

a. FALSE

b. TRUE

B

Topic : GF_JAVA_JAN10   Sub Topic : Servlets Question 24 3 Topic : JAVA, Sub-Topic : Servlets

What are the parameters of service() method ?

Choose most appropriate option.

a. Request, Response

b. HttpResponse,HttpServletRequest

c. HttpRequest,HttpResponse

d. ServiceResponse,ServiceRequest

e. ServletRequest,ServletResponse C

Page 20: Test Paper Solved

Topic : GF_JAVA_JAN10   Sub Topic : Servlets Question 25 3 Topic : JAVA, Sub-Topic : Servlets

What sort of things can we do by using response object?

Choose most appropriate option.

a. Add cookies

b. Redirect the browser to another URL

c. Set the HTTP status

d. All of the above

D

Topic : GF_JAVA_JAN10   Sub Topic : Servlets Question 26 3 Topic : JAVA, Sub-Topic : Servlets

Which of the following options are true for init()method of a servlet?

Choose two appropriate option.

a. A servlet's init method is called only once by the servlet container throughout the life of a servlet.

b. A servlet's init method is called each and every time when servlet is called.

c. init() method is not related to the servlets

d. A servlet's init method is called by the server immediately after the server constructs the servlet's instance

AD

Topic : GF_JAVA_JAN10   Sub Topic : Servlets Question 27 3 Topic : JAVA, Sub-Topic : Servlets

The interface ___________ will make the servlet container to allow only one thread to invoke the service() of doXXX() methods at a time .

Fill in the blank with an appropriate option.

a. javax.SingleThreadModel

b. javax.servlet.http.SingleThreadModel

c. java.servlet.ThreadModel

Page 21: Test Paper Solved

d. javax.servlet.SingleThreadedModel

e. javax.servlet.SingleThreadModel

ETopic : GF_JAVA_JAN10   Sub Topic : MultiThreading Question 28 3 Topic : JAVA, Sub-Topic : MultiThreading

Consider the below code:

public class Acc_Runnable implements Runnable { public void run() { System.out.println("Bang6 is called from Thread!"); } public static void main(String a[]) { new Thread(new Acc_Runnable()).start(); } }

What will happen if the above code is executed?

Choose most appropriate option.

a. Program will execute successfully, but nothing will be printed at console.

b. Bang6 is called from Thread! gets printed

c. Depends on the Java Scheduler hence output is not predictable.

B

Topic : GF_JAVA_JAN10   Sub Topic : MultiThreading Question 29 3 Topic : JAVA, Sub-Topic : MultiThreading

Refer to the code given in the attached figure. What will be the output of the code?

Click on the hyperlink to view the figure Choose most appropriate option.

a. thread is keyword and hence cannot be used as class name

b. 0

c. 1000

d. 100

e. None of the above. No clue

Page 22: Test Paper Solved

Topic : GF_JAVA_JAN10   Sub Topic : Collection API Question 30 3 Topic : JAVA, Sub-Topic : Collection API

A class implements Comparator interface and overrides compare(Object A, Object B) to return zero if _______ .

Fill in the blank with appropriate option.

a. A and B are equal

b. A less than B

c. A greater than B

A

Topic : GF_JAVA_JAN10   Sub Topic : Collection API Question 31 3 Topic : JAVA, Sub-Topic : Collection API

Consider the following code:

import java.util.*; public class Acc3 { public static void main(String [] args) { int [] [] x = new int [2] [2]; x[0] = new int[2]; x[1] = new int[2]; Map map = new HashMap(); map.put(x[0], "Accenture"); map.put(x[1],"High performance. Delivered"); Collection values = map.values(); System.out.println(values); } }

What will be the output of above code? Choose appropriate option.

a. [High performance. Delivered, Accenture]

b. [Accenture, High performance. Delivered]

c. [Accenture]

d. [High performance. Delivered]

A

Page 23: Test Paper Solved

Topic : GF_JAVA_JAN10   Sub Topic : IO Question 32 3 Topic : JAVA, Sub-Topic : IO

Consider the following code:

import java.io.*; public class Acc_Input { public static void main (String a[])throws IOException { BufferedReader i = new BufferedReader(new InputStreamReader(System.in)); String New; while ((New = i.readLine())!= null || New.length()!= 0) System.out.println(New); } }

Assume the input line as "I am an Accenturite" .

What will be the output of above code? Choose appropriate option.

a. I am an Accenturite

b. I

c. Accenturite

d. No output at the console

A

Topic : GF_JAVA_JAN10   Sub Topic : Servlets Question 33 3 Topic : JAVA, Sub-Topic : Servlets

Consider the below statement :

response.setContentType("bdc6.html");

This statement is used to set _____ . Fill in the blank with appropriate option.

a. Footers and Headers before returning of the content.

b. Headers before returning of the content.

c. Footers and Headers after returning of the content.

d. Headers after returning of the content.

B

Topic : GF_JAVA_JAN10   Sub Topic : IO Question 34 3 Topic : JAVA, Sub-Topic : IO

Page 24: Test Paper Solved

_____ can be used to write lines of characters to a file.

Fill in the blank with appropriate option.

a. BufferedWriter

b. BufferedReader

c. FileWriter

d. FileReader

C

Topic : GF_JAVA_JAN10   Sub Topic : Servlets Question 35 3 Topic : JAVA, Sub-Topic : Servlets

Consider the following code for Servlet-mapping

<servlet-mapping> <servlet-name>Servlet_Name</servlet-name> <url-pattern>/Servlet_Name</url-pattern> </servlet-mapping>

Which of the following option is valid with respect to the above code?

Choose appropriate option.

a. Option A :The concept of servlet-mapping is used for designing a pattern of webpage

b. Option B : The concept servlet-mapping is used for giving URL to the named Servlet.

c. Both Option A and Option B

d. None of Above.

B

Topic : GF_JAVA_JAN10   Sub Topic : Servlets Question 36 3 Topic : JAVA, Sub-Topic: Servlets

In a single servlet instance, init() method is invoked _____ times.

Fill in the blank with appropriate option.

a. Two

Page 25: Test Paper Solved

b. Only once

c. Many

B

Topic : GF_JAVA_JAN10   Sub Topic : Servlets Question 37 3 Topic : JAVA, Sub-Topic : Servlets

Refer to the code given in the attached figure. Assume all required packages are imported. What will be the output of the code?

Click on the hyperlink to view the figure Choose most appropriate option.

a. Calling service method

b. I am an ASE in Accenture

c. Compile time error

B

Topic : GF_JAVA_JAN10   Sub Topic : Servlets Question 38 3 Topic : JAVA, Sub-Topic : Servlets

Which of the following methods are used to handle HTML request and execute business logic functions?

Choose two appropriate options.

a. doGet()

b. DoGet()

c. DoPost()

d. doPost()

e. doPut()

A DTopic : GF_JAVA_JAN10   Sub Topic : Networking Question 39 3 Topic:Java,Sub-Topic:Networking

Page 26: Test Paper Solved

Identify classes that can be used for establishing TCP connections in Java programs.

Choose three appropriate options.

a. ServerSocket

b. Socket

c. URLConnection

d. MultigramSocket

Abc

Topic : GF_JAVA_JAN10   Sub Topic : Networking Question 40 3 Topic:Java,Sub-Topic:Networking

How do you create a connection using URLConnection classes to a particular URL?

Choose appropriate option.

a. URLConnection connection = accentureURL.openConnection();

b. URLConnection connection = accentureURL.getConnection();

c. URLConnection connection = accentureURL.setConnection();

d. URLConnection connection = accentureURL.Connection();

B

                                        Copyright 2006 - 2010 Accenture. All Rights Reserved. Accenture Confidential. For Internal Use Only.         Version History