Tuesday, 31 October 2017

#3. SCJP/OCJP Exams Questions & Answers-Which method signature follows the JavaBeans naming standards for modifying the itemld instance variable?



3. A programmer is designing a class to encapsulate the information about an inventory item. A JavaBeans component is needed to do this. The Inventory ltem class has private instance variables to store the item information:
10. private int itemId;
11. private String name;
12. private String description;

Which method signature follows the JavaBeans naming standards for
modifying the itemld instance variable?

A. itemID(int itemId)
B. update(int itemId)
C. setItemId(int itemId)
D. mutateItemId(int itemId)
E. updateItemID(int itemId)



Correct Answer: C

Explanation:
JavaBeans  के standard naming  convention के according अगर हम private  instance variable को modify करना है तोह इस तरीके से लिखते है | 
setXXX( datatype XXX);
इसलिए ऑप्शन C सही है | 

No comments:

Post a Comment

#45 to #51 SCJP/OCJP Exams Questions & Answers-

45. Given: 1. public class A { 2. public void doit() { 3. } 4. public String doit() { 5. return "a"; 6. } 7. ...