| |
|
Test your Java language skills - Quiz 1 |
|
|
|
Written by Content Team
|
|
Sep 12, 2006 at 11:04 PM |
|
Page 1 of 2 Most professional Java developers tend to get so busy with their specialization that they often lose touch with the basic Java language itself. So if you wish to test your Java skills and check if you still are in touch with the language, here's the first of our mini Java quizzes.
These questions are courtesy of Whizlabs Software
and will also help you prepare for the Sun Certified Java Programmer
Exam 5.0 (SCJP).
If you are looking for a user contributed database of
100s of Java questions, check out the Java Interview Questions Bank .
Question No. 1:
If the complete date/time information is Mon May 23 09:05:28 PM GMT+05:30 2005, what will be printed out by the following program?
class Format2 {
public static void main(String[] args){
Formatter fmt=new Formatter();
Calendar cal=Calendar.getInstance();
fmt.format("%tr %tZ",cal,cal);
System.out.println(fmt);
}
}
A. 09:05:28 PM GMT+05:30
B. 21:05:28 2005
C. Mon 21:05:28 GMT+05:30 2005
D. 21:05:28 GMT+05:30
E. May 23 09:05:28 PM GMT+05:30
Question No. 2:
What is the result of compiling and running the following code?
class StringBufferTest{
public static void main(String[] args){
1. StringBuffer result = new StringBuffer();
2. StringBuffer s=null;
3. result.append(s);
4. result.insert(0,"123");
5. System.out.println(result);
}
}
A.Compiler error at line 1
B.Compiler error at line 3
C.Compiler error at line 4
D.NullPointerException
E.StringIndexOutOfBoundsException
F.Prints "123null"
Try your best to solve these before you jump to the next page for answers.
<< Start < Previous 1 2 Next > End >> |
|
|
|