JavaBeat
Search JavaBeat

Certification Kits
SCJP 1.5 Exam Questions
SCJP 1.6 Exam Questions
SCWCD 5.0 Exam Questions
SCBCD 5.0 Exam Questions
SCJP 1.6 Links
SCJP 1.6 Home
What is new?
SCJP Books
Objectives
Mock Exams
NavigableSet
NavigableMap
GarbageCollection
Console
Finalize Method
Forums
SCJP Exam Voucher
Certification Links
SCJP 1.4
SCJP 1.5
SCJP 1.6
SCWCD 1.4
SCWCD 5.0
SCBCD 5.0
SCEA
SCEA 5.0
JavaBeat
Home
Articles
Tips
Code
QnA
Forums
400 Mock Questions on SCJP 1.6 - JUST Rs.300 or 10 USD
Send us mail to sales@javabeat.net
more details
Do you have paypal account? Click Here to pay now and get the questions.

SCJP 1.6 Mock Exams - Console (5 Questions)

5) What will be the output of the following program?


package console;

public class Ques02 {

	public static void main(String[] args) {
		
		int anInt = 100;
		double aDouble = 100.00;
		
		System.console().format("%2d - %1f", anInt, aDouble);
	}
}
  1. The program will output ‘100.000000 – 100’.
  2. The program will output ‘100 - 100.000000’.
  3. The program will throw a IllegalFormatConversionException at run-time.
  4. The program will output ‘100 – 100’.

Get more questions on Console

Answer

5) b.

Here the ordering of the arguments (anInt and aDouble) matters, not the formatting strings ‘%2 - %1d’. So the first output will be the value of anInt variable followed by a hyphen (‘-‘) followed by the value of aDouble variable.

400 Mock Questions on SCJP 1.6 - JUST Rs.300 or 10 USD
Send us mail to sales@javabeat.net
more details

Favorites
C# problem error
Java News
Webmaster Hosting Forum
Java Jobs
MyVideoLib
Latest QnA
SCJD Tips
When we start a thread by applying start() method on it ,how does it knows that to execute run()method?
About Wrapper class in Java
How to configure weblogic 7.0 in MyEclipse?
Static Block and Static Initializer in Java

JavaBeat Website (2004-2008), India
javabeat | about us | useful resources
Copyright (2004 - 2008), JavaBeat