Curioustab
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Take Free Test
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Take Free Test
Language Fundamentals Questions
Java — In an interface, which explicit declarations are equivalent to the implicit constant defined on line 3? Given: public interface Foo { int k = 4; // Line 3 } Pick the three equivalent explicit forms.
Java — Which declarations are valid inside an interface definition?
Java — Which one is a valid boolean variable declaration and initialization?
Java — What is the numerical range of a char (primitive type)?
In Java programming, which of the following is a valid declaration of a String variable?
Which of the following is a valid Java keyword (reserved word) recognized by the Java compiler?
In Java, which option both declares an int array and initializes it immediately with five specific numbers?
In Java, which three are valid declarations for a float variable among the following candidates?
Which of the following is a reserved Java keyword (cannot be used as an identifier)?
In Java, which three of the following are valid char declarations or assignments?
Java arrays default values: which four entries correctly describe default element values for the given types?
Which one of the following lists contains only valid Java language keywords (no identifiers or non-Java tokens)?
In Java, which three are legal array declarations among the following?
Which statement legally declares, constructs, and initializes a one-dimensional int array in Java?
Java arrays and command-line arguments: trace the output when copying args into a 2D array reference. public class CommandArgsThree { public static void main(String[] args) { String[][] argCopy = new String[2][2]; int x; argCopy[0] = args; // first row refers to args array x = argCopy[0].length; for (int y = 0; y < x; y++) { System.out.print(" " + argCopy[0][y]); } } } // Invocation: > java CommandArgsThree 1 2 3
Java arrays and command-line arguments: populating a larger array from args and printing names[2]. 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]); } } // Invocation: > java X a b
Java entry point rules: what happens when main is not declared static? public class F0091 { public void main(String[] args) { System.out.println("Hello" + args[0]); } } // Command line: > java F0091 world
Java command-line arguments and array bounds: trace the loop and identify the runtime behavior. public class CommandArgsTwo { public static void main(String[] argh) { int x; x = argh.length; // number of arguments for (int y = 1; y <= x; y++) { System.out.print(" " + argh[y]); // note: starts at 1 and uses <= } } } // Invocation: > java CommandArgsTwo 1 2 3
Java multidimensional arrays (jagged): accessing an uninitialized inner array element. public class TestDogs { public static void main(String[] args) { Dog[][] theDogs = new Dog[3][]; // only outer dimension allocated System.out.println(theDogs[2][0].toString()); } } class Dog { }
Java keywords and for-loop tracing: identify the compile-time outcome of using “signed”. 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 + ", "); } }
1
2