wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Please help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Please help" Watch "Please help" New topic
Author

Please help

pravink chougule
Greenhorn

Joined: Jan 18, 2007
Posts: 9
* 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

Joined: Aug 03, 2002
Posts: 7729
"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.


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
pravink chougule
Greenhorn

Joined: Jan 18, 2007
Posts: 9
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

Joined: Aug 03, 2002
Posts: 7729
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
Sheriff

Joined: Sep 28, 2004
Posts: 18876
    
  40

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


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Gudimella Chandana
Greenhorn

Joined: Dec 28, 2006
Posts: 7
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.
 
GeeCON Prague 2014
 
subject: Please help