click below
click below
Normal Size Small Size show me how
Java (Arrays)
| Identify the correct header for the “main” Method? | “public static void main(String[] args)” OR “public static void main(String args[])” “public static void main(String[] x)” OR “public static void main(String x[])” | “static void main(String[] args)” - this is incorrect because “main” method MUST be public. |
| public static void main(String argv[]) { System.out.println(“argv.length is ” + argv.length); } | If you run this program without passing any arguments, the program would display argv.length is 0. | < Blank > |
| Which code fragment would correctly identify the number of arguments passed via the command line to a Java application, excluding the name of the class that is being invoked? | int count = args.length; | < Blank > |
| How can you get the word “abc” in the main method from the following: | java Test “+” 3 “abc” 2 | args[2] |
| The __________ method sorts the array scores of the double[] type. | Answer is: | java.util.Arrays.sort(scores) |
| If a key is not in the list, the binarySearch method returns ___________ . | Answer is: | - (insertion point + 1) |
| What are logical operators? | ! (not), && (and), || (or), ^ (exclusive or) . These can be used to create a compound Boolean expression. | |
| Arithmetic Operators: | + (add), - (subtraction), * (multiplication), / (division), % (remainder) | |
| Relational (comparison) operators: | = (“assign” a value), == (used to check to see if numerical values are equal to one another), <, <=, >, >= . | |
| Identify primitive data types used in Java: | byte (8-bit), short (16-bit), int (32-bit), long (64-bit), float (32-bit), double (64-bit) | Methods for Scanner objects: nextByte(), nextShort(), nextInt(), nextLong(), nextFloat(), nextDouble() |