Question No: 101 – (Topic 2)

Mark works as a Programmer for InfoTech Inc. He develops a program that defines a class named Inventory that has an instance variable named NumOfItems. Which of the following properties will be applied by NumOfItems?

Each correct answer represents a complete solution. Choose all that apply.

It will not be visible in Static methods if it passed as a parameter.

It will be visible in Static methods if it passed as a parameter.

It will be available for all the instance methods of the class.

It becomes available for garbage collection if it is no longer in scope.

Answer: B,C,D

Question No: 102 – (Topic 2)

Which of the following statements are correct about the code given below?

lt;security-constraintgt;

lt;web-resource-collectiongt;

lt;web-resource-namegt;AccountServletlt;/web-resource-namegt;

lt;descriptiongt;This is an Account Servlet.lt;/descriptiongt;

lt;http-methodgt;GETlt;/http-methodgt;

lt;http-methodgt;POSTlt;/http-methodgt;

lt;http-methodgt;PUTlt;/http-methodgt;

lt;http-methodgt;DELETElt;/http-methodgt;

lt;url-patterngt;acme/AccountServletlt;/url-patterngt;

lt;/web-resource-collectiongt;

lt;/security-constraintgt;

Each correct answer represents a complete solution. Choose all that apply.

The delete http method is not allowed in the http-method element declaration.

If no http-method is specified in the web-resource-collection element, the security restriction will be applied to all http methods.

There should be at-least one url-pattern element otherwise, the lt;web-resource- collectiongt; will be ignored.

It is necessary that the web-resource-name must be specified in the web-resource- collection element.

It is not possible to define more than two http method in the web-resource-collection element.

It is necessary that the web-resource-name must be specified in the url of the url-pattern element.

Answer: B,C,D

Question No: 103 – (Topic 2)

You work as programmer for PassGuide.Inc. You have purchased a Web application named

SecureProgrammer that uses the programmatic authorization, and the security roles that are not used in your organization. Which of the following deployment descriptor elements must you use so that the SecureProgrammer application can work with your organization?

lt;security-role-refgt;

lt;security-rolegt;

lt;security-constraintgt;

lt;login-configgt;

Answer: A

Question No: 104 – (Topic 2)

You have the following code fragment of a Java program named test.

public void getData(){

ArrayList numbers=new ArrayList(); 14. for(int i=0; ilt;10;1 ){

int value=i*((int i) Math.random());

Integer obj=new Integer(value);

numbers.add(obj);

18. }

19. System.out.println(numbers);

20. }

On which of the following lines of code will the object referenced by obj be eligible for garbage

collection?

Line 18

Line 19

Line 17

Line 20

Answer: D

Question No: 105 – (Topic 2)

Which of the following init() method calls initializes a cipher object with a key in the SECRET_MODE?

cipher.init(2, key);

cipher.init(1, key);

cipher.init(3, key);

cipher.init(4, key);

Answer: C

Question No: 106 – (Topic 2)

Peter works as a Software Developer for Neon Inc. He is developing an application in Java. He declares an interface. Which of the following field declarations are valid within the body of an interface?

Each correct answer represents a complete solution. Choose three.

final static int answer=42;

public static int answer = 42;

private final static int answer=42;

public int answer=42;

int answer;

Answer: A,B,D

Question No: 107 – (Topic 2)

Given the following directory structure.

Assuming that the current directory is com, which of the below options can be used to create a jar file called TestJar.jar that contains all the files from the directory testApp?

jar -zf TestJar.jar

jar -cf TestJar.jar

jar -tf TestJar.jar

jar -cf TestJar.jar testApp

Answer: D

Question No: 108 – (Topic 2)

Which of the following elements contains the lt;filtergt; element in the deployment descriptor?

lt;servletgt;

lt;filtersgt;

lt;web-appgt;

lt;filter-mappinggt;

lt;servlet-mappinggt;

Answer: C

Question No: 109 – (Topic 2)

Which of the following classes is an engine class designed to provide conversions between opaque cryptographic keys and allows you to build an opaque key object from a given key specification?

KeyPair

KeyFactory

CertificateFactory

KeyPairGenerator

Answer: B

Question No: 110 – (Topic 2)

The java.util.logging package provides the classes and interfaces of the Java platform#39;s core logging facilities. Which of the following are the main target uses of logs?

Each correct answer represents a complete solution. Choose all that apply.