JavaBeat
SCJP 5.0 Home New to SCJP? Objectives Articles Mock Exams Tutorials Resources SiteMap & Links Forums  

SCJP 5.0 Questions
01. MockExam - 01
02. MockExam - 02
03. MockExam - 03
04. AutoBoxing - 1 (10 questions)
05. AutoBoxing - 2 (10 questions)
06. Generics 1 - 6 Questions
07. Generics 2 - 7 Questions
08. Generics 3 - 10 Questions
09. Generics 4 - 10 Questions
10. Generics 5 - 10 Questions
11. Generics 6 - 10 Questions
12. Enum 1 - 10 Questions
13. Enums 2 - 10 Questions
14. Enums 3 - 15 Questions
15. Var Args 1 - 10 Questions
16. Var Args 2 - 10 Questions
17. SCJP 5.0 Mock Questions -1
18. Declaration,Access Control-1
19.Java File IO Package - 1
20.Java File IO Package - 2
21.Language Features - 1
22.New Api's - 1 (10 questions)
23.New Api's - 2 (12 questions)
24.Objective - 1 (20 questions)
25.Objective - 2 (10 questions)
26.Objective - 3 (10 questions)
27.Objective - 4 (10 questions)
28.Objective - 5 (10 questions)
29.Objective - 6 (10 questions)
30.Objective - 7 (10 questions)
350 Mock Questions on SCJP 1.5 - JUST Rs.200 or 7 USD
Send us mail to sales@javabeat.net
more details

SCJP 5.0 Mock Exam -2

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


package scjp5_0.chap03;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

public class Ques04 {

	public static void main(String[] args) throws Exception{
		
		byte buffer[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'};
		InputStream inputStream = new ByteArrayInputStream(buffer);
		
		inputStream.read();inputStream.read();
		inputStream.skip(4);
		System.out.println((char)inputStream.read());
	}
}
  1. The program will raise a run-time exception telling that it is not possible to skip bytes in the middle of a reading operation.
  2. The program will output 'd'.
  3. The program will output 'e'.
  4. The program will output 'g'.

Answer:

4) d.
The read() operations will make the pointer to point to 'b'. Then the pointer is made to proceed to the next four characters by calling the skip() method. Now, the current pointer is pointing to the character 'f'. So, the next read() operation will return 'g'.

Get more questions on SCJP 1.5 topics

350 Mock Questions on SCJP 1.5 - JUST Rs.200 or 7 USD
Send us mail to sales@javabeat.net
more details

Sponsors
Webmaster Hosting Forum
Java Jobs
MyVideoLib
India News
Internet Advances
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 Media (2004-2008), India
javabeat | planetoss | links directory | advertise
Copyright (2004 - 2008), JavaBeat