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 Obj = New Bitset(5); 5. For (int I = 0; I < 5; ++i) 6. Obj.set(i); 7. Obj.clear(2); 8. System.out.print(obj.length() + " " + Obj.size()); 9. } 10. } |
|
Answer» obj.length() returns the length allotted to OBJECT obj at TIME of initialization and obj.SIZE() returns the size of current object obj, each BitSet element is GIVEN 16 bits therefore the size is 4 * 16 = 64, whereas length is still 5. Output: $ javac Bitset.java obj.length() returns the length allotted to object obj at time of initialization and obj.size() returns the size of current object obj, each BitSet element is given 16 bits therefore the size is 4 * 16 = 64, whereas length is still 5. Output: $ javac Bitset.java |
|