JavaCore Test 1 Which declaration of the main method below would allow a class to be started as a standalone program. public static int main(char args[]) public static void main(String args[]) public static void MAIN(String args[]) public static void main(String args) What is the meaning of the return data type void? An empty memory space is returned so that the developers can utilize it. void is not supported in Java void returns no data type. null Which of these are legal identifiers. number_1 number_a $1234 All of the above. Which of the following are Java keywords? throw void private All of the above. A lower precision can be assigned to a higher precision value in Java. For example a byte type data can be assigned to int type. True False Which of these are not legal identifiers. (A) 1alpha (B) xy+abc both A and B None of the above Which of the following are legal definitions of the main method that can be used to execute a class. public static int main(String args[]) public static void main(string args[]) public static void main(String args[]) public void main(String args) Which of the following statements about the Java language is true? Java supports only procedural approach towards programming. Both procedural and OOP are supported in Java. Java supports only OOP approach. None of the above. Which of the following are keywords in Java. implement friend synchronized NULL Which of these are legal array declarations or definitions? int[] []x[]; int x[5]; int *x; None of above What gets printed when the following code is compiled and run with the following command - java test 2 Select the one correct answer. public class test { public static void main(String args[]) { Integer intObj=Integer.valueOf(args[args.length-1]); int i = intObj.intValue(); if(args.length > 1) System.out.println(i); if(args.length > 0) System.out.println(i - 1); else System.out.println(i - 2); } } test -1 0 1 test Which of the following statements is false about objects? An instance of a class is an object Objects do not permit encapsulation Objects can access both static and instance data Object is the super class of all other classes Which of these are legal identifiers. a. number_1 b. number_a c. $1234 d. -volatile a d a, b a, b, c The class Hashtable is used to implement which collection interface. Select the one correct answer. List Set Map SortedSet TreeMap class is used to implement which collection interface. Select the one correct answer. SortedSet Tree Set SortedMap Given a one dimensional array arr, what is the correct way of getting the number of elements in arr. Select the one correct answer. arr.length arr.length - 1 arr.size arr.length() What happens when the following code is compiled and run. Select the one correct answer. for(int i = 1; i i; j--) assert i!=j {System.out.println(i); } </pre> The class compiles and runs, but does not print anything. The number 1 gets printed with AssertionError The program generates a compilation error. The number 2 gets printed with AssertionError What gets displayed on the screen when the following program is compiled and run. Select the one correct answer. protected class example { public static void main(String args[]) { String test = "abc"; test = test + test; System.out.println(test); } } The class does not compile because the top level class cannot be protected. The program does not compile because statement "test = test + test" is illegal. The program prints "abcabc" The program prints "abc" In the following class definition, which is the first line (if any) that causes a compilation error. Select the one correct answer. public class test { public static void main(String args[]) { char c; int i; c = 'A'; // 1 i = c; //2 c = i + 1; //3 c++; //4 } } The line labeled 1. The line labeled 2. The line labeled 3. All the lines are correct and the program compiles. Which of the following is a Java keyword.a. externb. synchronizedc. volatiled. friende. friendlyf. transientg. thish. then e, g, h b, c, f, g b, c all of above. Schreibe einen Kommentar Antworten abbrechenDu musst angemeldet sein, um einen Kommentar abzugeben.