0

programming languages Online Quiz - 328

Description: programming languages Online Quiz - 328
Number of Questions: 20
Created by:
Tags: programming languages
Attempted 0/20 Correct 0 Score 0

Given the following jsp line select the correct statements:

  1. 1) It is a valid line that can be used to initialize the servlet that implements the jsp file.

  2. 2) It won't compile as no identifer can start with jsp not _jsp.

  3. 3) It will serve as the servlet initialization if the function's name is _jspInit.

  4. 4) There is no way to initialize a jsp's implementation class servlet.


Correct Option: A

What will be printed out if this jsp code?

  1. 1) It won't compile.

  2. 2) It will print the default client's Web browser locale.

  3. 3) It will print the default web server Locale.

  4. 4) It will the first language specified in the Accept-Language request's header.


Correct Option: A

What is the return type of the getLastModified method of HttpServlet?

  1. 1) java.util.Date

  2. 2) java.sql.Date.

  3. 3) int.

  4. 4) long


Correct Option: D

What will be the result of running the following jsp file taking into account that the Web server has just been started and this is the first page loaded by the server?

  1. 1)It won't compile

  2. 2)It will print the session id.

  3. 3)It will produce a NullPointerException as the getSession(false) method's call returns null, cause no session had been created.

  4. 4)It will produce an empty page.


Correct Option: B
  1. 1) There is no such method.

  2. 2) It searches the attribute in all 4 scopes.

  3. 3) It searches the attribute in page scope.

  4. 4) The method is findAttribute(String name, int scope)


Correct Option: B

. Which are mandatory elements of the web-resouce-collection element?

  1. 1) web-resource-name

  2. 2) url-pattern

  3. 3) http-method

  4. 4) auth-constraint


Correct Option: A,B

What are the types returned by the ServletContext method getResource and getResourceAsStream?

  1. 1) ServletContext doesn't have one of these two methods.

  2. 2) String and InputStream

  3. 3) URL and InputStream

  4. 4) URL and StreamReader


Correct Option: C

Which of the following statements regarding HttpRequest methods are correct?

  1. 1) getHeaderNames returns an Enumeration

  2. 2) getHeaders returns a String[]

  3. 3) getHeaderValues returns a String[]

  4. 4) getIntParameter returns an int


Correct Option: A

Which statements are correct about the method PageContext.include?

  1. 1) There is no such method.

  2. 2) It has two paramters: request and response

  3. 3) It has one parameter of type String which is the relative URL of the page to include.

  4. 4) This method is appropiate to use within a Tag class.


Correct Option: C,D

Which of the following statements PageConext methods pushBody and popBody are true?

  1. 1) pushBody is called by the jsp container after doStartTag and before doAfterBdy

  2. 2) pushBody is called by the jsp container before doInitBody

  3. 3) popBody is called by the jsp container after doAfterBody and before doEndTag

  4. 4) popBody is called by the jsp container after doEndTag


Correct Option: A,C

. Is it true that all tags have a parent tag,which is null for top-level tags, and is the innermost containing tag for nested tags.

  1. 1) yes

  2. 2) no

  3. 3) only the second part of the statement is true.

  4. 3) only the first part of the statement is true.


Correct Option: A

You are calling the method HttpServletResponse.sendRedirect(String path) and you want to make sure that the user continues in the same session. How do you that?

  1. 1) By calling the method with an absolute path as the argument

  2. 2) By enconding the path with HttpServletResponse.endcodeURL method

  3. 3) By enconding the path with HttpServletResponse.endcodeRedirectURL method

  4. 4) If you use sendRedirect the session is lost.


Correct Option: C
  1. 1) It only contains the element role-name (besides element description)

  2. 2) Only the role-name specified in security-role-ref can be used

  3. 3) It is a subelement of web-resource-collection

  4. 4) It is related to authentication


Correct Option: A

class a { public staic void main(String ar[]) { String s="abcxyz"; s.substring(2,5) System.out.println(s); } }

  1. cxy

  2. abcxyz

  3. cxyz

  4. bcxy


Correct Option: B

A class without main method can be compiled successfuly.

  1. True

  2. False


Correct Option: A

class a { public staic void main(String ar[]) { String s="abcxyz"; s.substring(2,5); System.out.println(s); } }

  1. cxy

  2. abcxyz

  3. bcxy

  4. cxyz


Correct Option: B

Find the output of this program.1. void main(){ float j; j=1000*1000; printf("%f",j); }

  1. 1000000

  2. Overflow

  3. None

  4. Error


Correct Option: C

Find the output of this program. 1. void main(){ float j; j=1000*1000; printf("%f",j); }

  1. 1000000

  2. Overflow

  3. None

  4. Error


Correct Option: C

Find the output of this program. main() { int a[10]; printf("%d",*a+1-*a+3) ; }

  1. Compiler error

  2. 3

  3. -2

  4. 4


Correct Option: D

Find the output of this program. main() { int i=0; while(+(+i--)!=0) i-=i++; printf("%d",i); }

  1. -1

  2. 1

  3. 0

  4. Compiler error


Correct Option: A
- Hide questions