DURGA’s SCJP Material DURGASOFT 202,2nd Floor,HUDA...

This preview shows page 1 - 3 out of 7 pages.

DURGA’s SCJP Material DURGASOFT, # 202,2 nd Floor,HUDA Maitrivanam,Ameerpet, Hyderabad - 500038, 040 – 64 51 27 86, 80 96 96 96 96, 9246212143 | Page 1
Image of page 1

Subscribe to view the full document.

DURGA’s SCJP Material DURGASOFT, # 202,2 nd Floor,HUDA Maitrivanam,Ameerpet, Hyderabad - 500038, 040 – 64 51 27 86, 80 96 96 96 96, 9246212143 | Page 2 4. Flow Control Q: 01 Given: 10. public class Bar { 11. static void foo( int... x ) { 12. // insert code here 13. } 14. } Which two code fragments, inserted independently at line 12, will allow the class to compile? (Choose two.) A. foreach( x ) System.out.println(z); B. for( int z : x ) System.out.println(z); C. while( x.hasNext() ) System.out.println( x.next() ); D. for( int i=0; i< x.length; i++ ) System.out.println(x[i]); Answer: B, D Q: 02 Click the Task button. Solution: int [ ] y={1,2,4,8,16,32}; System.out.print("output : "); for(int x : y ) { System.out.println(x); System.out.println(" ");
Image of page 2