Questions
If the last index of array list is 12, what is the length of the array?
- 13
- 12
- 11
- Unknown
What is the index of the last element of array list[]?
- list[list.length]
- list.length-1
- list[-1]
- list[list.length-1]
How do you declare an array of ten Strings?
- String[] running = new String[10];
- String[] running = String[10];
- String[10] running = new String[];
- String running = String[10];
How do you declare an array of booleans?
- boolean[] running;
- boolean running[];
- boolean[10] running;
- boolean running[10];
What Java keyword can be used to end a method?
- stop
- break
- return
- done
What Java keyword is used to create objects?
- new
- create
- construct
- abracadabra
What is the value of "This is Patrick".length()?
- Syntax error
- 15
- 13
- 17
The technique of breaking a problem down into smaller, more easily managed pieces, is called:
- Designing the algorithm
- Procedural decomposition
- Stupid
- Patrick
Which error prevents Java from running your program?
- Runtime error
- Logic error
- Syntax error
- Spelling error
Who coined the terms "bug" and "debug"?
- Aniket
- Grace Hopper
- Ada Lovelace
- Katherine Johnson
Which of the following are valid Java String literals?
- ""Hello", she said"
- "Falling\n\tleaves"
- "Can't tell"
- If he'll just listen once
What is the value of "1" + "3" + 2?
- 15
- 132
- 42
- 6
What is the value of (int) Math.abs((double) 5 / -4 )?
- 1
- 2
- 1.00
- 1.25
If x is an integer > 10, how would you print the ten's digit?
- x / 10 % 10
- x % 10
- x / 10
- x % 10 * 10
Which of the following type conversions requires an explicit type cast?
- int to double
- int to String
- double to int
- double to String
What is the value of 3 * 7 + 8.4 / 2?
- 25.2
- 25
- 12.6
- 14.6
If str="foolishness", which expression returns "ess"?
- str.substring(8)
- str.substring(9)
- str.substring(8,4)
- str.substring(9,3)
If str="foolishness", which expression returns "lish"?
- str.substring(3,7)
- str.substring(4,8)
- String.substring(str, 3, 7)
- str.substring(3,6)
Given x is an integer, which of the following is a valid conditional?
- if (x > 2 or < 5)
- if (x = 4)
- if (x < 2 && x > 5)
- if (x)
What values can be generated by the following code: (int) (Math.random() * 3)
- Floating point numbers between 0 and 3.
- Integers between 0 and 2.
- Integers between 0 and 3.
- Doubles from 0 to 3, including 0 but not including 3.
How do you create an array of 20 integers?
- int[20] myArray;
- int[] myArray = new int[20];
- int myArray = [20];
- int[] myArray = int[20];
Which of following constant declarations is valid?
- public static final void foo;
- public static final int USERS = 20;
- public FINAL SIZE = 10;
- public static boolean final BORED = TRUE;
Which loop will iterate 10 times?
- for (int i=0; i<10; i++)
- for (x=0; x<10; x++)
- for (int y=1; y<10; y++)
- for (int j=0; j<=10; j++)
Which of the following class names follows proper Java naming conventions?
- myClass
- The_Classiest_Class
- MyClassyClass
- aniketsclasstoendallclasses
Which of the following variable names follows proper Java naming conventions?
- another_variable_name
- Int
- myIdentifier
- variabletrackinghowmanyuserslogin
Which of following are legal Java identifiers?
- 2answer
- maybe
- foo+bar
- can't_decide
Which value can you assign to a boolean variable?
- true
- 1
- null
- False
Which is the correct signature for the main() method?
- public static int main(String args)
- public static void main(String arg)
- public static final main()
- public static void main(String[] args)
Which of following is not a primitive data type?
- boolean
- String
- int
- double