Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

rms question

 
Yi Meng
Ranch Hand
Posts: 270
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Q8. Which statement is true about following code segment. Suppose all objects are valid objects. (Select One)
rs.addRecord(rec1, 0, rec1.length);
rs.addRecord(rec2, 0, rec2.length);
rs.addRecord(rec3, 0, rec3.length);
rs.deleteRecord(2);
rs.getRecord(2, data, 0);
A. This code will successfully compile and run.
B. This code will compile fine but will throw an exception at runtime.
C. This code will successfully compile and run if �rs.deleteRecord(2)� is removed.
D. This code will not be compiled.

The suggested answer is c, but why not b?
 
Eduardo Rodrigues
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the same...
Why not 'b'??
For me this code will throw a InvalidRecordIDException.
Some clarifications needed here!
 
Eduardo Rodrigues
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've just tried and the Exception was thrown...
See you guys...
Bye
 
Mehdi Chaouachi
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The suggested answer is c, but why not b?

Who suggested this answer, if it is from sun then it is probably correct.
 
Terence Doyle
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Answer c seems correct to me.
After the 3 addRecord() calls there are 3 records in the RecordStore.
Don't confuse the addRecord() and setRecord() methods. The add record doesn't indicate the 'recordId'.
Hope that helps,
 
Eduardo Rodrigues
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For me is 'b'.
When you call

The Record which index is 2 is DELETED from the RecordStore.
Then you call

that throws a InvalidRecordIDException.
This question is very simple, I don't know why is generating so much doubts.

Bye
[ February 18, 2004: Message edited by: Eduardo Rodrigues ]
 
Cleverson Schmidt
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
B AND C are correct
[ February 18, 2004: Message edited by: Cleverson Schmidt ]
 
Eduardo Rodrigues
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Man, I didn't paid attention to the options...
Yes, B ANDC are correct!
Bye
 
Forrest Xu
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
compare with C, B is the best choice
 
Michael Zhao
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think both B and c are correct.
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For me, both b and c are correct as well... Where does that question come from?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic