• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Please help

 
pravink chougule
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
* There was a qs with a character array being declared as a class member as :

Char ch[] = new Char[4] .

This was not initailized anywhere . But this was used to acess the fle data with a reader as follows :

While(ch = (int)out.read(ch) != -1){

Sysout´┐Ż.

}

the file contained abcdef

Answers:

1.)null

2.)aaaaaa

3.)abcdef

4.)abcdab

5.)ababc
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"There was a qs "


Please tell us exactly where you have got this question.
Also please edit your question title to something more meaningful than "please help". Thanks.
 
pravink chougule
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It was in one of the questions asked in one of the company interview exam...
Will appreciate if you could give me the answer for the same..
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The whole question looks like nonsense to me. What is the out on which the method read is called? And what is Char? Is it some special wrapper class? And While that's not even a Java keyword. And it's trying to assign an int to an array reference. Looks like that company is just trying to waste peoples time.
 
Henry Wong
author
Marshal
Pie
Posts: 21024
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To be fair, it was an "interview exam". Something tells me that most of the "nonsense" is probably because it is from memory. Regardless, I agree with Barry, the question in its current incomplete state, just "waste peoples time".

Henry
 
Gudimella Chandana
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Pravin,

While posting questions please verify whether you are posting them correctly or not.



The above code result in compiler error. First of all check the Statement what you are trying to assign to what and what you are checking and what the method will be returning.
Secondly there is no method in the inputstream which takes the char array as an argument.



Try out with the above code.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic