C and Java Programming Fundamentals Quiz

Test your knowledge of C and Java programming concepts, including C operators, pointers, and control structures, plus Java EJB, servlets, threads, and exception handling.

20 Questions Published

Questions

Question 1 Multiple Choice (Multiple Answers)

Which three are true about the HttpServletRequestWrapper class?

  1. The HttpServletRequestWrapper is an example of the Decorator pattern.
  2. The HttpServletRequestWrapper can be used to extend the functionality of a servlet request.
  3. A subclass of HttpServletRequestWrapper CANNOT modify the behavior of the getReader method.
  4. An HttpServletRequestWrapper may be used only by a class implementing the javax.servlet.Filter interface.
  5. An HttpServletRequestWrapper CANNOT be used on the request passed to the RequestDispatcher.include
  6. An HttpServletRequestWrapper may modify the header of a request within an object implementing the
Question 2 Multiple Choice (Single Answer)

Which arithmetic operations can result in the throwing of anArithmeticException?

  1. +
  2. *
  3. -
  4. /
Question 3 Multiple Choice (Single Answer)

What does getSession(false) will do?

  1. Create new session if the session does not already exist
  2. Returns null if session does not already exist
  3. Returns false
  4. Destroy the session
Question 4 Multiple Choice (Single Answer)

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

  1. HttpSession
  2. ServletConfig
  3. ServletContext
  4. HttpServletRequest
  5. HttpServletResponse
Question 5 Multiple Choice (Single Answer)

What is the difference between an object and an instance?

  1. No difference, both are the same
  2. An Object maynot have a class definition, but an instance must have a class definition
  3. An Object must have a class definition, but an instance may not have a class definition
  4. Object and Instance should have different class definitions. It can not be the same.
Question 6 True/False

Is a skeleton created by RMI?

  1. True
  2. False
Question 7 True/False

Jdk1.4 also contain the tool interface that is JVMTI which is a profiling tool in jdk1.5

  1. True
  2. False
Question 8 Multiple Choice (Multiple Answers)

If a method is declared as protected, where may the method be accessed?

  1. Interfaces of the same package and other packages
  2. Classes of the same package
  3. Classes of the same package and other packages
  4. Interfaces of the same package
Question 9 True/False

A dead thread can be restarted by calling the start() method again on that object

  1. True
  2. False
Question 10 True/False

The default value of the boolean type is

  1. True
  2. False
Question 11 True/False

EJB and Java beans can be run on many systems?

  1. True
  2. False
Question 12 Multiple Choice (Single Answer)

he following code is not well-written. What does the program do? Void main() { int a=1, b=2, c=3,d=4; printf("%d %d", a, b); printf (" %d %d", c, d); }

  1. Run-Time Error
  2. Compile-Time Error
  3. 1 2 3 4
  4. None of above
Question 13 Multiple Choice (Single Answer)

What will be the output of the following program : void main() { int a=1,b=2,c=3; c=(--a, b++)-c; printf("%d %d %d",a,b,c); }

  1. 0 3 -3
  2. Compile-Time Error
  3. 0 3 -1
  4. 0 3 0
Question 14 Multiple Choice (Single Answer)

What will be the output of the following program : void main() { int a=1,b=2,c=3,d=4,e; e=(a,a)+(b,c)+(c,d)-(d,b); printf("%d", e); }

  1. Compile-Time Error
  2. 10
  3. 6
  4. 2
Question 15 Multiple Choice (Single Answer)

What will be the output of the following program: void main() { float val=2.; printf("%.2",val); }

  1. Compile-Time error
  2. 2.00
  3. %.2
  4. 2.000000
Question 16 Multiple Choice (Single Answer)

What will be the output of the following program : void main() { int a=5; int b=6;; int c=a+b; printf("%d",c); }

  1. Compile-Time Error
  2. Run-Time Error
  3. 11
  4. None of above
Question 17 Multiple Choice (Single Answer)

What will be the output of the following program : void main() { int i,j; for (i=1; i<=3; i++) for (j=1; j<3; j++) { if (i == j) continue; if ((j % 3) > 1) break; printf("%d",i); } }

  1. 2,3
  2. 3,2
  3. 2,2
  4. 3,3
Question 18 Multiple Choice (Single Answer)

What will be the output of the following program : #define swap(a,b) temp=a; a=b; b=temp; void main() { static int a=5,b=6,temp; if (a > b) swap(a,b); printf("a=%d b=%d",a,b); }

  1. a=5 b=6
  2. a=6 b=5
  3. a=6 b=0
  4. None of the above
Question 19 Multiple Choice (Single Answer)

What will be the output of the following program : void main() { unsigned int val=5; printf("%u %u",val,val-11); }

  1. Compile-Time error
  2. 5 -6
  3. 5 65530
  4. none of the above
Question 20 Multiple Choice (Single Answer)

What will be the output of the following program : void main() { int x=4,y=3,z=2; &z=&x*&y; printf("%d",z); }

  1. Compile-Time error
  2. Run-Time Error
  3. 24
  4. Unpredictable