• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About HttpURLConnection's setDoInput

 
Himai Minh
Ranch Hand
Posts: 1141
4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In EPractice lab, there is a question like this:

//Only important words are shown:
Select one:
A. Both doInput and doOutput flags must be true to interact with web service provider. To achieve this, we must call setDoInput(true) and setDoOutput(true) method before obtaining connection.
B. Only doInput flag must be true....
C. Only doOutput flag must be true to interact with web service provider. To achieve this, we must call setDoOutput(true) method before obtaining connection.
D. Both doInput and doOutput flags must be false......

I believe C is the answer. By default, doInput flag is true. Even if we don't call setDoInput(true), this doInput flag is still true. And it won't harm if we call setDoInput(true). And it is not a must to call setDoInput(true). However, it is a must to call setDoOutput(true) because doOutput is false by default.

But the given answer is A.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic