• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

I/O

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. what is the correct format of reading a line of
String objects ?
a) FileInputStream fis = new
FileInputStream("Filename.txt");
b) DataInputStream dis = new DataInputStream(new
FileInputSTream("FileName.txt"));
c) DataInputStream dis = new DataInputStream(new
FileInputSTream("FileName.txt"), "r");
I think it's a,b
please reply.
 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Janani,
Answer c is no doubt wrong because of its syntax. it holds good
only a RandomAccess file.
Answer a is also wrong because there is no method by which u can
read a line using the FileInputStream. It can only read bytes of
data rather than in terms of Strings or chars or primitives.
Answer b is the correct answer.
The question is which of the following correctly reads a LINE of
String objects.
Hope this helps.
------------------
Regards,
V. Kishan Kumar
 
hema janani
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Kishan
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes ,
the above things are good reasons
answer b is correct
srinivasan.e
 
Ranch Hand
Posts: 919
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
IMHO, none of them would work...
The case of the FileInputStream() method in (b) is incorrect (there's no upper-case T in the method name):
DataInputStream dis = new DataInputStream(new FileInputSTream("FileName.txt"));
Call me Mr Picky Pedant, but the exam does call for exactitude.
 
Do not meddle in the affairs of dragons - for you are crunchy and good with ketchup. Crunchy tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic