0

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

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

AI Explanation

To answer this question, you need to understand the concept of object serialization.

Option A) Deserialization - This option is incorrect because deserialization refers to the process of reading the state of an object from a byte stream, not writing it.

Option B) Serialization - This option is correct. Serialization is the process of converting the state of an object into a byte stream, which can be easily stored or transmitted.

Option C) Interface - This option is incorrect. An interface is a programming construct used to define a contract for implementing classes, but it is not directly related to the process of writing the state of an object to a byte stream.

Option D) All of the Above - This option is incorrect. Only option B, serialization, is the correct answer.

The correct answer is B) Serialization. This option is correct because it accurately describes the process of writing the state of an object to a byte stream.

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

  1. True

  2. False


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
  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

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

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: 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: 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

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

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

what is the output of the following Program

  1. True

  2. False


Correct Option: B

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

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

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

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

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

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

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

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() { 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
- Hide questions