Java Fundamentals and Web Technologies Practice Test

Comprehensive Java practice test covering core language concepts, collections, threading, JDBC, JSP, and servlets.

25 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

What is the numerical range of char?

  1. 0 to 32767
  2. 0 to 65535
  3. -256 to 255
  4. -32768 to 32767
Question 2 Multiple Choice (Single Answer)

Which of the following statements are true?

  1. The Iterator interface declares only three methods: hasNext, next and remove.
  2. The ListIterator interface extends both the List and Iterator interfaces.
  3. The ListIterator interface provides forward and backward iteration capabilities.
  4. The ListIterator interface provides the ability to modify the List during iteration.
  5. The ListIterator interface provides the ability to determine its position in the List.
  1. 2, 3, 4 and 5
  2. 1, 3, 4 and 5
  3. 3, 4 and 5
  4. 1, 2 and 3
Question 3 Multiple Choice (Single Answer)

What will be the output of the program?

public class ExamQuestion6 
{
    static int x; 
    boolean catch()
    {
        x++; 
        return true; 
    } 
    public static void main(String[] args)
    {
        x=0; 
        if ((catch() | catch()) || catch()) 
            x++; 
        System.out.println(x); 
    } 
}
  1. 1
  2. 2
  3. 3
  4. Compilation Fails
Question 4 Multiple Choice (Single Answer)

What is not true for a Java bean?

  1. There are no public instance variables.
  2. All persistent values are accessed using getxxx and setxxx methods.
  3. It may have many constructors as necessary.
  4. All of the above are true of a Java bean.
Question 5 Multiple Choice (Single Answer)

What is invoked via HTTP on the Web server computer when it responds to requests from a user's Web browser?

  1. A Java application
  2. A Java applet
  3. A Java servlet
  4. None of these
Question 6 Multiple Choice (Single Answer)

What will be the output of the program?
String s = "hello";
Object o = s;
if( o.equals(s) )
{
System.out.println("A");
}
else
{
System.out.println("B");
}
if( s.equals(o) )
{
System.out.println("C");
}
else
{
System.out.println("D");
}

  1. A
  2. B
  3. C
  4. D
  1. 1 and 3
  2. 2 and 4
  3. 3 and 4
  4. 1 and 2
Question 7 Multiple Choice (Single Answer)

Which method must be defined by a class implementing the java.lang.Runnableinterface?

  1. void run()
  2. public void run()
  3. public void start()
  4. void run(int priority)
Question 8 Multiple Choice (Single Answer)

Which collection class allows you to access its elements by associating a key with an element's value, and provides synchronization?

  1. java.util.SortedMap
  2. java.util.TreeMap
  3. java.util.TreeSet
  4. java.util.Hashtable
Question 9 Multiple Choice (Single Answer)

What is the numerical range of char?

  1. 0 to 32767
  2. 0 to 65535
  3. -256 to 255
  4. -32768 to 32767
Question 10 Multiple Choice (Single Answer)

What will be the output of the program?
try
{
Float f1 = new Float("3.0");
int x = f1.intValue();
byte b = f1.byteValue();
double d = f1.doubleValue();
System.out.println(x + b + d);
}
catch (NumberFormatException e)
{
System.out.println("bad number");
}

  1. 9.0
  2. bad number
  3. Compilation fails on line 13.
  4. Compilation fails on line 14.
Question 11 Multiple Choice (Single Answer)

Which two statements are true?

  1. Deadlock will not occur if wait()/notify() is used
  2. A thread will resume execution as soon as its sleep duration expires.
  3. Synchronization can prevent two objects from being accessed by the same thread.
  4. The wait() method is overloaded to accept a duration.
  5. The notify() method is overloaded to accept a duration.
  6. Both wait() and notify() must be called from a synchronized context.
  1. 1 and 2
  2. 3 and 5
  3. 4 and 6
  4. 1 and 3
Question 12 Multiple Choice (Single Answer)

Which of the following statements is true?

  1. If assertions are compiled into a source file, and if no flags are included at runtime, assertions will execute by default.
  2. As of Java version 1.4, assertion statements are compiled by default.
  3. With the proper use of runtime arguments, it is possible to instruct the VM to disable assertions for a certain class, and to enable assertions for a certain package, at the same time.
  4. When evaluating command-line arguments, the VM gives -ea flags precedence over -da flags.
Question 13 Multiple Choice (Single Answer)

How many JDBC driver types does Sun define?

  1. One
  2. Two
  3. Three
  4. Four
Question 14 Multiple Choice (Single Answer)

Who invented Java?

  1. Netscape
  2. Microsoft
  3. Sun
  4. None of the above is correct
Question 15 Multiple Choice (Single Answer)

To run a compiled Java program, the machine must have what loaded and running?

  1. Java virtual machine
  2. Java compiler
  3. Java bytecode
  4. A Web browser
Question 16 Multiple Choice (Single Answer)

Which JDBC driver Type(s) can be used in either applet or servlet code?

  1. Both Type 1 and Type 2
  2. Both Type 1 and Type 3
  3. Both Type 3 and Type 4
  4. Type 4 only
Question 17 Multiple Choice (Single Answer)

What is sent to the user via HTTP, invoked using the HTTP protocol on the user's computer, and run on the user's computer as an application?

  1. A Java application
  2. A Java applet
  3. A Java servlet
  4. None of the above is correct
Question 18 Multiple Choice (Single Answer)

What servlet processor was developed by Apache Foundation and Sun?

  1. Apache Tomcat
  2. Apache Web server
  3. Sun servlet processor
  4. None of the above is correct
Question 19 Multiple Choice (Single Answer)

You need to store elements in a collection that guarantees that no duplicates are stored. Which one of the following interfaces provide that capability?

  1. Java.util.Map
  2. Java.util.List
  3. Java.util.Collection
  4. None of the above
Question 20 Multiple Choice (Single Answer)

What programming language(s) or scripting language(s) does Java Server Pages (JSP) support?

  1. VBScript only
  2. Jscript only
  3. Java only
  4. All of the above are supported
Question 21 Multiple Choice (Single Answer)

A JSP is transformed into a(n):

  1. Java applet.
  2. Java servlet.
  3. Either 1 or 2 above.
  4. Neither 1 nor 2 above.
Question 22 Multiple Choice (Single Answer)

What is bytecode?

  1. Machine-specific code
  2. Java code
  3. Machine-independent code
  4. None of the above is correct
Question 23 Multiple Choice (Single Answer)

________ is an open source DBMS product that runs on UNIX, Linux and Windows.

  1. MySQL
  2. JSP/SQL
  3. JDBC/SQL
  4. Sun ACCESS
Question 24 Multiple Choice (Single Answer)

Which JDBC driver Type(s) can you use in a three-tier architecture and if the Web server and the DBMS are running on the same machine?

  1. Type 1 only
  2. Type 2 only
  3. Both Type 3 and Type 4
  4. All of Type 1, Type 2, Type 3 and Type 4
Question 25 Multiple Choice (Single Answer)

Where is metadata stored in MySQL?

  1. In the MySQL database metadata
  2. In the MySQL database metasql
  3. In the MySQL database mysql
  4. None of the above is correct