Java Fundamentals and Web Technologies Practice Test
Comprehensive Java practice test covering core language concepts, collections, threading, JDBC, JSP, and servlets.
Questions
What is the numerical range of char?
- 0 to 32767
- 0 to 65535
- -256 to 255
- -32768 to 32767
Which of the following statements are true?
- The Iterator interface declares only three methods: hasNext, next and remove.
- The ListIterator interface extends both the List and Iterator interfaces.
- The ListIterator interface provides forward and backward iteration capabilities.
- The ListIterator interface provides the ability to modify the List during iteration.
- The ListIterator interface provides the ability to determine its position in the List.
- 2, 3, 4 and 5
- 1, 3, 4 and 5
- 3, 4 and 5
- 1, 2 and 3
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
- 2
- 3
- Compilation Fails
What is not true for a Java bean?
- There are no public instance variables.
- All persistent values are accessed using getxxx and setxxx methods.
- It may have many constructors as necessary.
- All of the above are true of a Java bean.
What is invoked via HTTP on the Web server computer when it responds to requests from a user's Web browser?
- A Java application
- A Java applet
- A Java servlet
- None of these
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");
}
- A
- B
- C
- D
- 1 and 3
- 2 and 4
- 3 and 4
- 1 and 2
Which method must be defined by a class implementing the java.lang.Runnableinterface?
- void run()
- public void run()
- public void start()
- void run(int priority)
Which collection class allows you to access its elements by associating a key with an element's value, and provides synchronization?
- java.util.SortedMap
- java.util.TreeMap
- java.util.TreeSet
- java.util.Hashtable
What is the numerical range of char?
- 0 to 32767
- 0 to 65535
- -256 to 255
- -32768 to 32767
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");
}
- 9.0
- bad number
- Compilation fails on line 13.
- Compilation fails on line 14.
Which two statements are true?
- Deadlock will not occur if wait()/notify() is used
- A thread will resume execution as soon as its sleep duration expires.
- Synchronization can prevent two objects from being accessed by the same thread.
- The wait() method is overloaded to accept a duration.
- The notify() method is overloaded to accept a duration.
- Both wait() and notify() must be called from a synchronized context.
- 1 and 2
- 3 and 5
- 4 and 6
- 1 and 3
Which of the following statements is true?
- If assertions are compiled into a source file, and if no flags are included at runtime, assertions will execute by default.
- As of Java version 1.4, assertion statements are compiled by default.
- 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.
- When evaluating command-line arguments, the VM gives -ea flags precedence over -da flags.
How many JDBC driver types does Sun define?
- One
- Two
- Three
- Four
Who invented Java?
- Netscape
- Microsoft
- Sun
- None of the above is correct
To run a compiled Java program, the machine must have what loaded and running?
- Java virtual machine
- Java compiler
- Java bytecode
- A Web browser
Which JDBC driver Type(s) can be used in either applet or servlet code?
- Both Type 1 and Type 2
- Both Type 1 and Type 3
- Both Type 3 and Type 4
- Type 4 only
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?
- A Java application
- A Java applet
- A Java servlet
- None of the above is correct
What servlet processor was developed by Apache Foundation and Sun?
- Apache Tomcat
- Apache Web server
- Sun servlet processor
- None of the above is correct
You need to store elements in a collection that guarantees that no duplicates are stored. Which one of the following interfaces provide that capability?
- Java.util.Map
- Java.util.List
- Java.util.Collection
- None of the above
What programming language(s) or scripting language(s) does Java Server Pages (JSP) support?
- VBScript only
- Jscript only
- Java only
- All of the above are supported
A JSP is transformed into a(n):
- Java applet.
- Java servlet.
- Either 1 or 2 above.
- Neither 1 nor 2 above.
What is bytecode?
- Machine-specific code
- Java code
- Machine-independent code
- None of the above is correct
________ is an open source DBMS product that runs on UNIX, Linux and Windows.
- MySQL
- JSP/SQL
- JDBC/SQL
- Sun ACCESS
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?
- Type 1 only
- Type 2 only
- Both Type 3 and Type 4
- All of Type 1, Type 2, Type 3 and Type 4
Where is metadata stored in MySQL?
- In the MySQL database metadata
- In the MySQL database metasql
- In the MySQL database mysql
- None of the above is correct