Set 18

Multiple Choice Question

QID: 
357

Identify the valid for loop constructs assuming the following declarations:

Object o = null; 
Collection c = //valid collection object.
 int[][] ia = //valid array

Select 2 options

A. for(o : c){ } 
B. for(final Object o2 :c){ } 
C. for(int i : ia) { } 
D. for(Iterator it : c.iterator()){ } 
E. for(int i : ia[0]){ }

Multiple Choice Question

QID: 
356

What will the following code print when compiled and run:

public class TestClass {        
public static void main(String[] args){     
   int k = 2;    
    while(--k){         
   System.out.println(k);     
   }  
  } }

Select 1 option

A. 1 
B. 1 0 
C. 2 1 
D. 2 1 0 
E. It will keeping printing numbers in an infinite loop. 
F. It will not compile.

Multiple Choice Question

QID: 
355

What will the following code print?

void crazyLoop(){   
int c = 0;   
JACK: while (c < 8){     
 JILL: System.out.println(c);     
  if (c > 3) break JILL; else c++; 
  } 
  }

Select 1 option

 A. It will not compile. 
B. It will throw an exception at runtime. 
C. It will print numbers from 0 to 8 
D. It will print numbers from 0 to 3 
E. It will print numbers from 0 to 4 

Multiple Choice Question

QID: 
354

What will the following program snippet print?

int i=0, j=11;
do{
if(i > j) { break; }
j--;
}while( ++i < 5);
System.out.println(i+" "+j);

Select 1 option

A. 5 5
B. 5 6
C. 6 6
D. 6 5
E. 4 5

Multiple Choice Question

QID: 
353

What will the following code print?

void crazyLoop(){
int c = 0;
JACK: while (c < 8){
JILL: System.out.println(c);
if (c > 3) break JACK; else c++;
}
}

Select 1 option

A. It will not compile.
B. It will throw an exception at runtime.
C. It will print numbers from 0 to 8
D. It will print numbers from 0 to 3
E. It will print numbers from 0 to 4

Pages

Search the Web

Custom Search

Searches whole web. Use the search in the right sidebar to search only within javajee.com!!!

Quick Notes Finder Tags

Activities (1) advanced java (1) agile (3) App Servers (6) archived notes (2) ArrayLists (1) Arrays (2) Best Practices (12) Best Practices (Design) (3) Best Practices (Java) (7) Best Practices (Java EE) (1) BigData (3) Chars & Encodings (6) coding problems (2) Collections (15) contests (3) Core Java (All) (52) course plan (2) Database (12) Design patterns (8) dev tools (3) downloads (2) eclipse (9) Essentials (1) examples (14) Exception (1) Exceptions (4) Exercise (1) exercises (6) Getting Started (18) Groovy (2) hadoop (4) hibernate (77) hibernate interview questions (6) History (1) Hot book (4) http monitoring (2) Inheritance (4) intellij (1) java 8 notes (4) Java 9 (1) Java Concepts (7) Java Core (7) java ee exercises (1) java ee interview questions (2) Java Elements (16) Java Environment (1) Java Features (4) java interview points (4) java interview questions (4) javajee initiatives (1) javajee thoughts (3) Java Performance (6) Java Programmer 1 (11) Java Programmer 2 (8) Javascript Frameworks (1) Java SE Professional (1) JSP (1) Legacy Java (1) linked list (3) maven (1) Multithreading (16) NFR (1) No SQL (1) Object Oriented (9) OCPJP (4) OCPWCD (1) OOAD (3) Operators (4) Overloading (2) Overriding (2) Overviews (1) policies (1) programming (1) Quizzes (17) references (2) resources (1) restful web service (3) Searching (1) security (10) Servlets (8) Servlets and JSP (31) Site Usage Guidelines (1) Sorting (1) source code management (1) spring (4) spring boot (1) Spring Examples (1) Spring Features (1) spring jpa (1) Stack (1) Streams & IO (3) Strings (11) SW Developer Tools (2) testing (1) troubleshooting (1) user interface (1) vxml (8) web services (1) Web Technologies (1) Web Technology Books (1) youtube (1)