True or False 1)Suppose you have the following declaration: int xyz = 4; Then, i
ID: 3587941 • Letter: T
Question
True or False
1)Suppose you have the following declaration: int xyz = 4; Then, in the body of a switch statement block
case xyz: System.out.println(“4”);
break;
is legal.
2)A variable declared as static cannot ever be modified, once it has been declared and initialized.
3)Consider the statement: throw new IllegalArgumentException(); This always causes the program to immediately exit.
4)If a non abstract class A implements interface B, class A does not have to define all the methods in interface B. But if it doesn't class A cannot be instantiated.
5)The binary search algorithm will work properly on all integer arrays.
6)The declaration FilledOval[ ][ ] A = new FilledOval[20][30]; creates 600 FilledOval instances using the FilledOval() constuctor.
Explanation / Answer
1) Suppose you have the following declaration:
int xyz = 4; Then, in the body of a switch statement block
case xyz: System.out.println(“4”);
break;
is legal. ------------------------ > False
Explanation: this is illegal; because case expressions must be constant expressions.
2) A variable declared as static cannot ever be modified, once it has been declared and initialized.
-------------------> False
Explanation: static variables can be modified.
3) Consider the statement: throw new IllegalArgumentException(); This always causes the program to immediately exit. -------------------> False
Explanation: this would not cause the program to immediately exit; the exception can be caught in catch block and error message can be printed after that.
4)If a non abstract class A implements interface B, class A does not have to define all the methods in interface B. But if it doesn't class A cannot be instantiated. -------------------> True
Explanation: when A implements interface B either A has to implement all the methods of B or A should be declared as abstract class and an abstract class cannot be instantiated.
5)The binary search algorithm will work properly on all integer arrays. -------------------> False
Explanation: binary search algorithm will work only for sorted arrays whether it is an integer array or a float array that does not matter but array must be sorted for this to work properly.
6)The declaration FilledOval[ ][ ] A = new FilledOval[20][30]; creates 600 FilledOval instances using the
FilledOval() constructor. -------------------> True
Explanation: FilledOval[ ][ ] A = new FilledOval[20][30]; this declaration would create 600 instances of FilledOval class and by default it uses FilledOval() constructor.
/*If this helps you, please let me know by giving a positive thumbs up. In case you have any queries, do let me know. I will revert back to you. Thank you!!*/
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.