Java Certifications
www.javacertifications.com
 home  scjp1.5  scjp1.6  scwcd 1.5  scjp 1.5 questions  scjp 1.6 questions  scwcd 1.5 questions  scjp 1.5 success kit  scjp 1.6 success kit  
  JavaCertifications.net provides java certfication tutorials and mock questions.  


Bookmark and Share |||     Share   
805 scjp 1.6 questions with explanations ||| 788 scjp 1.5 questions with explanations ||| 650 SCWCD 5.0 questions with explanations

Tutorials


SCJP : Flow Control Mock Exam Practice Questions

Questions no -1 
What is the output for the below code ?
public class Test{

public static void main(String[] args) {
  int i1=1;
 switch(i1){
     case 1:
              System.out.println("one");
     case 2:
              System.out.println("two");
     case 3:
              System.out.println("three");
}
}
}

options A)one two three B)one C)one two D)Compile error. Correct answer is : A Explanations : There is no break statement in case 1 so it causes the below case statements to execute regardless of their values.
Questions no -2 
What is the output for the below code ?
public class Test {
	public static void main(String[] args) {
		  char c = 'a';
	
		 switch(c){
		     case 65:
		              System.out.println("one");break;
		     case 'a':
		              System.out.println("two");break;
		     case 3:
		              System.out.println("three");
		}
		
		}
	

}

options A)one two three B)one C)two D)Compile error - char can't be in switch statement. Correct answer is : C Explanations : Compile properly and print two.
scjp 1.5 | scjp 1.6 | scwcd 1.5
Java Certifications
www.javacertifications.net