java-programming-language-fundamentals Related Question Answers

1. Which three are legal array declarations? int [] myScores []; char [] myChars; int [6] myScores; Dog myDogs []; Dog myDogs [7];





2. public interface Foo { int k = 4; / Line 3 / } Which three piece of codes are equivalent to line 3? final int k = 4; public int k = 4; static int k = 4; abstract int k = 4; volatile int k = 4; protected int k = 4;





3. Which one of the following will declare an array and initialize it with five numbers?





4. Which three are valid declarations of a char? char c1 = 064770; char c2 = 'face'; char c3 = 0xbeef; char c4 = \u0022; char c5 = '\iface'; char c6 = '\uface';





5. Which is the valid declarations within an interface definition?





6. Which one is a valid declaration of a boolean?





7. Which three are valid declarations of a float? float f1 = -343; float f2 = 3.14; float f3 = 0x12345; float f4 = 42e7; float f5 = 2001.0D; float f6 = 2.81F;





8. Which is a valid declarations of a String?


9. What is the numerical range of a char?





10. What will be the output of the program? public class CommandArgsThree { public static void main(String [] args) { String [][] argCopy = new String[2][2]; int x; argCopy[0] = args; x = argCopy[0].length; for (int y = 0; y < x; y++) { System.out.print(" " + argCopy[0][y]); } } } and the command-line invocation is > java CommandArgsThree 1 2 3





11. What will be the output of the program? public class CommandArgs { public static void main(String [] args) { String s1 = args[1]; String s2 = args[2]; String s3 = args[3]; String s4 = args[4]; System.out.print(" args[2] = " + s2); } } and the command-line invocation is > java CommandArgs 1 2 3 4





12. public class F0091 { public void main( String[] args ) { System.out.println( "Hello" + args[0] ); } } What will be the output of the program, if this code is executed with the command line: > java F0091 world





13. What will be the output of the program? public class TestDogs { public static void main(String [] args) { Dog [][] theDogs = new Dog[3][]; System.out.println(theDogs[2][0].toString()); } } class Dog { }





14. What will be the output of the program ? public class Test { public static void main(String [] args) { signed int x = 10; for (int y=0; y<5; y++, x--) System.out.print(x + ", "); } }





15. What will be the output of the program? public class CommandArgsTwo { public static void main(String [] argh) { int x; x = argh.length; for (int y = 1; y <= x; y++) { System.out.print(" " + argh[y]); } } } and the command-line invocation is > java CommandArgsTwo 1 2 3





16. In the given program, how many lines of output will be produced? public class Test { public static void main(String [] args) { int [] [] [] x = new int [3] [] []; int i, j; x[0] = new int[4][]; x[1] = new int[2][]; x[2] = new int[5][]; for (i = 0; i < x.length; i++) { for (j = 0; j < x[i].length; j++) { x[i][j] = new int [i + j + 1]; System.out.println("size = " + x[i][j].length); } } } }






17. What will be the output of the program? public class X { public static void main(String [] args) { String names [] = new String[5]; for (int x=0; x < args.length; x++) names[x] = args[x]; System.out.println(names[2]); } } and the command line invocation is > java X a b





18. Which four options describe the correct default values for array elements of the types indicated? int -> 0 String -> "null" Dog -> null char -> '\u0000' float -> 0.0f boolean -> true





19. Which one of these lists contains only Java programming language keywords?






20. Which will legally declare, construct, and initialize an array?





21. Which is a reserved word in the Java programming language?






22. Which is a valid keyword in java?





Terms And Service:We do not guarantee the accuracy of available data ..We Provide Information On Public Data.. Please consult an expert before using this data for commercial or personal use | Powered By:Omega Web Solutions
© 2002-2017 Omega Education PVT LTD...Privacy | Terms And Conditions
Question ANSWER With Solution