TRUE OR FALSE 1.Method declarations void A(double x, integer k){}; and void A(in
ID: 3587876 • Letter: T
Question
TRUE OR FALSE
1.Method declarations void A(double x, integer k){}; and
void A(integer k, double x) {}; have identical signatures
2.(“Give me Liberty”.split(“ “).length) evaluates to 3
3.The declaration FilledOval[ ][ ] A = new FilledOval[20][30]; creates 600 FilledOval instances using the FilledOval() constuctor.
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.A class declared as final cannot be inherited via the extends keyword.
6.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.
7.A class can implement multiple interfaces
8.If the following statements are the only two statements in a method,
String X = new String(“thing one”); and String Y= new String(”thing one”); then
X.equals(Y) evaluates to true, but X == Y evaluates to false within that method.
9.Consider the statement: throw new IllegalArgumentException(); This always causes the program to immediately exit.
10.It is legal to define more than one class in a java source file as long as only one of them is public.
Explanation / Answer
1. Method signature includes method name and parameters. Here parameters of both the methods are different. So, they are not identical FALSE
2. Split() function splits the given string according to the given delimiter and returns an array. length property returns the length of the array which is 3. TRUE
3. FilledOval[][] A = new FilledOval[20][30]. This statement creates a 2d array for FilledOval instances. However, the instances of the class are not initialized unless we explicitly initialize like A[i][j] = new FilledOval. So, it is FALSE
4. A non abstract class implementing an interface must override all the methods in the interface. FALSE
5. TRUE. A final class can'nt be inherited
6. Case statement expects a constant variable. So, this is invalid. TRUE
7. TRUE, A class can implement multiple interfaces, but it can extend only one class
8. == returns true, if both point to the same object, which is not correct as both are different objects. So, it is FALSE
equals method checks for equality of two strings, this returns true. So, givne statement is TRUE
9. Whenever an exception is thrown, program terminates, unless it is handled using try catch blocks. TRUE
10. yes, we can define any java classes in a single source file. Only one of them can be public at max TRUE
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.