Welcome Guest | Sign in | Register
Flow Control - Discussion Page For Q.2807 | Java Programming Questions and Answers | Java Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > Flow Control > Questions and Answers

Q: Which one is correct option : 

1. public class Example7 {
2. public static void main(String args[]) {
3 . Example7 e7 = new Example7();
4. int b = ? ;
5. e7.Movie(b);
6. }
7. public void Movie(int q) {
8. switch (q) {
9. case 1:
10. System.out.print("me ");
11. case 2:
12 .System.out.print("myself ");
13 .break;
14. case 3:
15. System.out.print("Irene ");
16. default:
17. System.out.print("Movie");
18. }}}

Which input-output option is correct :
A. a = 4, Output = " Movie"
a=3,Output="Irene Movie"
B. a=0, Output="me myself"
a = 4, Output = " Movie"
C. a=3,Output="Irene Movie"
a= 1, Output = " me"
D. a= 1, Output = " me"
a = 4, Output = " Movie"

Answer and Explanation

Answer:a = 4, Output = " Movie"

a=3,Output="Irene Movie"

Explanation:
Since break is in between case1 & case 2 , the case switch will continue until it meets to break or end of the program. Input 0 & 1 produce -'Movie' & 'me myself' respectively.

Comment on this Question

Name:

Loading...




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.