0
Alien head

programming languages Online Quiz - 99

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

main() { int i=-1,j=-1,k=0,l=2,m; m=i++&&j++&&k++||l++; printf("%d %d %d %d %d",i,j,k,l,m); }

  1. 1 3 1 0 0

  2. 0 1 0 1 3

  3. 0 0 3 1 1

  4. 0 0 1 3 1


Correct Option: D

main() { int c[ ]={2.8,3.4,4,6.7,5}; int j,p=c,*q=c; for(j=0;j<5;j++) { printf(" %d ",*c); ++q; } for(j=0;j<5;j++){ printf(" %d ",p); ++p; } }

  1. 3 4 6 5 2 2 2 2 2 2

  2. 4 6 5 2 2 2 2 2 2 3

  3. 2 2 2 3 4 6 5 2 2 2

  4. 2 2 2 2 2 2 3 4 6 5


Correct Option: D

main() { static int var = 5; printf("%d ",var--); if(var) main(); }

  1. 1 2 3 4 5

  2. 5 4 3 2 1

  3. compilation error

  4. None


Correct Option: B

1.main() { char s[ ]="man"; int i; for(i=0;s[ i ];i++) printf("%c%c%c%c",s[ i ],(s+i),(i+s),i[s]); }

  1. mmmmaaaannnn

  2. aaaammmmnnnn

  3. aaaannnnmmmm

  4. Compilation Error


Correct Option: A

what is the output of the following program

  1. compilation error at line 1

  2. compilation error at line 2

  3. compilation error at line 3

  4. 2

  5. Runtime Exception


Correct Option: D

what is the output of the following program

  1. compilation error at line 1

  2. compilation error at line 2

  3. compilation error at line 3

  4. compilation error at line 4

  5. 3

  6. Runtime Exception


Correct Option: A

Output of the following program

  1. compilation error at line 1

  2. compilation error at line 2

  3. compilation error at line 3

  4. compilation error at line 4

  5. 3

  6. Runtime Exception


Correct Option: D

Output of the following program

  1. compilation error at line 1

  2. compilation error at line 2

  3. compilation error at line 3

  4. compilation error at line 4

  5. RuntimeException

  6. 3


Correct Option: E

What is the output of the following Program.

  1. 3

  2. compilation error at line 1

  3. compilation error at line 2

  4. compilation error at line 3

  5. compilation error at line 4


Correct Option: B

what is the output of the following Program

  1. True

  2. False


Correct Option: B

Servlet A receives a request that it forwards to servlet B within another webapplication in the same web container. Servlet A needs to share data with servlet B and that data mustnot be visible to other servlets in A's web application. In which object can the data that A shares with Bbe stored?

  1. HttpSession

  2. ServletConfig

  3. ServletContext

  4. HttpServletRequest

  5. HttpServletResponse


Correct Option: D

A programmer has an algorithm that requires a java.util.List that provides an efficient implementation of add(0,object), but does NOT need to support quick random access. What supports these requirements?

  1. java.util.Queue

  2. java.util.ArrayList

  3. java.util.LinearList

  4. java.util.LinkedList


Correct Option: D

Given: classA {} class B extends A {} class C extends A {} class D extends B {} Which three statements are true? (Choose three.)

  1. The type List is assignable to List.

  2. The type List is assignable to List>.

  3. The type List is assignable to List extends B>.

  4. The type List extends B> is assignable to List extends A>.

  5. The type List is assignable to any List reference.


Correct Option: B,C,D

Given: 11. public static void append(List list) { list.add(”0042”); } 12. public static void main(String[] args) { 13. List intList = new ArrayList(); 14. append(intList); 15. System.out.println(intList.get(0)); 16. } ‘What is the result?

  1. 42

  2. 0042

  3. An exception is thrown at runtime

  4. Compilation fails because of an error in line 13


Correct Option: D

Given: 11. List list = // more code here 12. Collections.sort(list, new MyComparator()); Which code will sort this list in the opposite order of the sort in line 12?

  1. Collections.reverseSort(list, new MyComparator());

  2. Collections.sort(list, new MyComparator());

  3. Collections.sort(list, new InverseComparator(

  4. Collections.sort(list, Collections.reverseOrder(


Correct Option: D

Given the JSP code: and the Classic tag handler code: 5. public int doStartTag() throws JspException { 6. // insert code here 7. // return int 8. } Assume there are no other "foo" attributes in the web application. Which invocation on the pageContext object, inserted at line 6, assigns "bar" to the variable x?

  1. String x = (String) pageContext.getAttribute("foo");

  2. String x = (String) pageContext.getRequestScope("foo");

  3. It is NOT possible to access the pageContext object from within doStartTag.

  4. String x = (String)


Correct Option: D

In order for a source code file, containing the public class Test, to successfully compile, which of the following must be true?

  1. It must have a package statement

  2. It must be named Test.java

  3. It must import java.lang

  4. It must declare a public class named Test


Correct Option: B

Through _________ , you can control what parts of a program can access the members of a class

  1. Encapsulation

  2. Class

  3. Inheritance

  4. Polymorphism


Correct Option: A

servlet.xml is the file used to define a servlet mapping

  1. True

  2. False


Correct Option: B

The process of writing the state of an object to a byte stream is called as

  1. Deserialization

  2. Serialization

  3. Interface

  4. All of the Above


Correct Option: B
+ View questions