InterviewSolution
Saved Bookmarks
| 1. |
What Is The Output Of This Program? 1. Import Java.util.*; 2. Class Bitset { 3. Public Static Void Main(string Args[]) { 4. Bitset Obj1 = New Bitset(5); 5. Bitset Obj2 = New Bitset(10); 6. For (int I = 0; I < 5; ++i) 7. Obj1.set(i); 8. For (int I = 3; I < 13; ++i) 9. Obj2.set(i); 10. Obj1.and(obj2); 11. System.out.print(obj1); 12. } 13. } |
|
Answer» OBJ1.and(obj2) returns an BitSet object which CONTAINS elements common to both the object obj1 and obj2 and stores this BitSet in INVOKING object that is obj1. Hence obj1 contains 3 & 4. Output: $ javac Bitset.JAVA obj1.and(obj2) returns an BitSet object which contains elements common to both the object obj1 and obj2 and stores this BitSet in invoking object that is obj1. Hence obj1 contains 3 & 4. Output: $ javac Bitset.java |
|