Java J2EE Portal
Enterprise Java Station
J2EE curve
Java News / Articles
Java News / Articles
India Java User Groups
EJB 3.0 - Java Persistence API in Action
J2EE vs JavaEE - Simplify programming
Processing...
Buy Java, Deals On Software Technology Store
Click here for great deals on computers, laptops, software and books
Test your Java language skills - Quiz 2 PDF Print
Written by Content Team   
Oct 12, 2006 at 08:50 AM
Test your Java skills and check if you are in touch with the core language. Here's the second of our mini Java quizzes.

These questions are courtesy of Whizlabs Software and are meant to 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 or check out Java Questions Quiz One.

Question No. 1: What is the result of compiling and running the following code?

class PrintTest{

public static void main(String[] args) {

double d=222.4578;
System.out.printf("% .2f",d);

}

}

A.Does not compile
B.Throws IllegalFormatConversionException
C.Prints 222.46
D.Prints 222.45
E.Prints 2.224578
F.Prints .2224578

Question No. 2 What is the result of compiling and running the following code, assuming that the file bb.txt does not exist?

class WriterTest{

public static void main(String[] args) throws IOException{

Writer w=new BufferedWriter(new FileWriter("bb.txt")); // Line1
w.write(1); // Line2
w.close();

}

}

A.Compiler error
B.FileNotFoundException thrown at line 1
C.IOException thrown at line 2
D.None of these

Question No. 3 Which of the following statements are true about the default implementation of the public int hashCode() method of the Object class?

A.The Object class does not provide any implementation for the hashCode method; every class must override it.
B.As far as it may be practically possible, the hashCode method defined by the Object class does return distinct integers for distinct objects.
C.For two object references referring to the same object, the hashCode method returns the same integer.
D.It returns a fixed number that internally represents the Object class for the JVM.
E.Only choice D is correct.

The next page has the answers and explanations




Add This Feed Button

Enter your Email


Java Expert Interviews
Mukesh Hegde NCStudio IDE
Java IDE in a brand new avatar. Making development server centric.
Bruce Johnson
Google Web Toolkit isn't just another way to create mediocre Ajax applications
MarkSchiefelbein-BackbaseAjaxFramework
All Ajax development can happen serverside using the Backbase framework and JSF
Processing...
Go to top of page  Home |
SiteMap

Copyright 2004 to 2008 Rightrix Solutions. All rights reserved. All product names are trademarks of their respective companies. Java and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. Rightrix Solutions and IndicThreads.com are independent of Sun Microsystems, Inc.

Views expressed at IndicThreads.com reflect the views of the authors alone, and do not necessarily reflect those of IndicThreads.com. IndicThreads.com and it's authors are not responsible for reader comments and opinions.

Enterprise Java J2EE JEE Portal >> IndicThreads.com