Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question 26 of HFSJ Final mocktest

 
geeta vemula
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Given:
Which of the following lines of code, if inserted independently at Line 5, will cause the text within the ctherwise tag to display? (Choose all that apply)
A. books.add("");
B. books.add(null);
C. books.clear();
D. books.add("Head First");
E. books = null;


Answer is BD,

I thought it would be E. Also the explanation gviven in the book is not satisfying. What is the correct answer?
 
Omer Haderi
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

the answer is C and E. Maybe there is a typo!

A, B and D are wrong because all of them add something to the books list and the list is NOT empty.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic