JAVA
2.7K subscribers
73 photos
111 files
76 links
Download Telegram
Given the following declaration, which expression return the size of the array, assuming the array has been initialized? Select the one correct answer.
int[] array;
Anonymous Quiz
24%
array[].length()
14%
array.length()
17%
array[].length
26%
array.length
5%
array[].size()
14%
array.size()
Given the following code which statement is true?

public class Program
{
public static void main(String[] args) {
int k=0;
int l=0;
for(int i=0;i<=3;i++){
k++;
if(i==2){
break;
}
l++;
}
System.out.println(k+" "+l);
}
}
Consider the following Java Interface:
interface Pet{
void play();
} Suppose we want to code the Dog class, which is not an abstract class, and implement the pet interface. Which of the following actions needs to be performed in the given scenario? Choose the best options: A) Declare the Dog class to extend the Pet interface and override the abstract method play. B) State "Dog implements Pet" in the class declaration. The play method is automatically inherited from the pet interface. C) State "Dog implements Pet" in the class declaration and provides an implementation for the play method in the code of Dog class. D) Implement the play method in the Dog class. The Java compiler automatically deduces that the class Dog implements the corresponding interface.
Options
Anonymous Quiz
34%
A
34%
B
26%
C
5%
D
Determine the out of given code snippet?
public class Program
{
int i=1;
int j;
class B extends Program{//line 4
int k=3;//line 5
}
public static void main(String[] args) {
B.k=2;//line 8
System.out.println(i+" "+k);
}
}
public class Program
{
public static void main(String[] args) { int[] a1={1,2,3,4}; int[] a2=new int[5]; for(int i=0;i<a1.length;i++){ a2[i]=a1[i]; } System.out.println(a2[4]); } }
Anonymous Quiz
14%
0
29%
4
47%
ArrayIndexOutOfBoundException
10%
NullPointerException
Suppose you were Implementing a data structure to store information about the instruments on specification at an instruments dealer showroom. Of the following data structure, which one is the right one to use?
Anonymous Quiz
18%
Unordered Array
18%
Sorted Array
20%
LinkedList
14%
Binary search tree
29%
HashMap
public class Program
{
public static void main(String[] args) {
byte a=10;
float b;
int c;
b=(float)++a*a;
c=(short)b;
System.out.println(a++ + ++b +.1);
System.out.println(b +.1);
System.out.println(c +.1);
}
}
which of the following Exception is thrown by Jvm when code uses negative size while initializing an array
Anonymous Quiz
25%
NullPointerException
12%
NumberFormatException
25%
IllegalArgumentException
37%
NegativeArraySizeException