JavaCore Test 9 Which of these statements are legal. a. int arr[][] = new int[5][5]; b. int []arr[] = new int[5][5]; c. int[][] arr = new int[5][5]; d. int[] arr = new int[5][]; e. int[] arr = new int[][5]; a, b, c, d, e a, b a, b, c, d a, b, c What is returned when the method substring(2, 4) is invoked on the string "example"? Include the answer in quotes as the result is of type String. "xamp" "xm" "am" "xa" A class can have many methods with the same name as long as the number of parameters or type of parameters is different. This OOP concept is known as Method Overriding Method Invocating Method Labeling Method Overloading Which of these are Java keywords. a. TRUE b. volatile c. transient d. native e. interface f. then g. new d, e, f, g b, d, f, g a, b, d, g b, c, d, e, g What gets printed when the following program is compiled and run? class xyz { public static void main(String args[]) { int i,j,k; for (i = 0; i < 3; i++) { for(j=1; j < 4; j++) { for(k=2; k<5; k++) { if((i == j) && (j==k)) System.out.println(i); } } } } } 0 1 2 3 What is the name of collection interface used to maintain non-unique elements in order. SortedSet Map Set List Which of the following statement is true about the assert statement. The program terminates on its first AssertionError. A possible syntax of assert statement is assert logical_expression If logical_expression evaluates to true, the program generates an AssertionError. If a Java class contains assert statements, then it must be compiled with -1.4 option. When a program having assertions is run, -assertion option must be specified, otherwise the assertions get ignored. Which of the following is correct? a. The native keyword indicates that the method is implemented in another language like C/C++. b. The only statements that can appear before an import statement in a Java file are comments. c. The method definitions inside interfaces are public and abstract. They cannot be private or protected. d. A class constructor may have public or protected keyword before them, nothing else. c, d a, c b, c a, b Which of the following is considered as a blue print that defines the variables and methods common to all of its objects of a specific kind? Real data types Class Method Object Using up to four characters, write the Java representation of octal literal 6. 06 006 0006 all of above Using up to four characters what is the Java representation of the number 23 in hex? 0x19 0x17 0x18 0x20 What is the name of collection interface used to maintain unique elements. Map Set List All of above Which of the following are valid constructors within a class Test. a. test() { } b. Test() { } c. void Test() { } d. private final Test() { } e. abstract Test() { } f. Test(Test t) { } g. Test(void) { } b, f b, c c, f b, d What gets printed on the standard output when the class below is compiled and executed. public class ShortCkt { public static void main(String args[]) { int i = 0; boolean t = true; boolean f = false, b; b = (t | ((i++) == 0)); b = (f | ((i+=2) > 0)); System.out.println(i); } } 0 1 2 3 Is this True or False. In Java an abstract class cannot be sub-classed. False True What is the result of evaluating the expression 14 ^ 23. 26 25 24 23 What are the two parts of a value of type double? Length, Denominator Significant Digits, Exponent Mode, Numerator Length, Numerator What is the minimum value of char type. -215 - 1 -28 0 -215 What gets printed when the following program is compiled and run? class test { static boolean check; public static void main(String args[]) { int i; if(check == true) i=1; else i=2; if(i=2) i=i+2; else i = i + 4; System.out.println(i); } } 3 4 5 The program does not compile because of the statement if(i=2) What is the name of collection interface used to maintain mappings of keys to values. Map SortedSet List Set Schreibe einen Kommentar Antworten abbrechenDu musst angemeldet sein, um einen Kommentar abzugeben.