What is a string?
An object of the String class that represents a sequence of characters.
Define an Array List that holds integer values and is called "boosh".
ArrayList<int> boosh = new ArrayList<int>();
what is 110 in decimal
6
How can you traverse a 2D array
using nested loops
On average, which of the following sort methods is the fastest:
Selection Sort
Merge Sort
Insertion Sort
Merge Sort
Can a string be changed after it has been created?
Once created, a string cannot be changed and none of its methods can change the string. This is because it immutable.
.add() method
11110
What is an ArrayIndexOutOfBoundsException
Error given when the code tries to access an invalid index for a given array
What order will this list be in after the 3rd pass of selection sort:
64, 25, 12, 22, 11
11, 12, 22, 25, 64
What returns in the following code:
String s = new String ("classicaayush");
s.substring(2,8);
assica
What will be printed as a result of the code?
public static void main(String[] args)
{
ArrayList<String> list = new ArrayList<String>();
list.add("e");
list.add(0, "yo");
list.add("bob");
list.add(2,"3");
list.add("hi");
list.add(1, "yan");
System.out.println(list);
}
[yo, yan, e, 3, bob, hi]
What is 11 in Hexadecimal
B
Fill in the missing code to print out [47, 51, 20]
public static void main(String[] args)
{
int[][] arr = { {47,3,12},{51,74,20} };
*MISSING CODE*
}
System.out.println(arr[0][0]);
System.out.println(arr[1][0]);
System.out.println(arr[1][2]);
What order will the list be in after the 5th pass of insertion sort:
12, 8, 41, 22, 34, 2, 56
8, 12, 22, 34, 41, 2, 56
The class Scroll is meant to take the first letter of a string and put it at the end. Fill in the missing code segment to make the class work as specified.
public class Scroll {
public static String scroll (String s1){
return (*MISSING CODE*);
}
s1.substring(1,s1.length()) + Character.toString(s1.charAt(0))
//could be other solutions
The smallest method is meant to find the smallest value in a list. Fill in the missing code segment so it works as specified:
public static int smallest(ArrayList<Integer> list)
{
int smallest = list.get(0);
for (int i = 1; i < 20; i++)
{
if(*MISSING CODE*)
{
smallest = list.get(i);
}
}
}
(list.get(i) <= smallest)
what is 11101001 in decimal
233
What does this method do:
public static double something(int[][] nums){
int x = 0;
int y = 0;
for (int i = 0; i < nums.length; i++)
for (int j = 0; j < nums[i].length; j++) {
x += nums[i][j];
y ++;
}
return (double)x/y;
}
finds the average of the numbers in the array.
Use merge sort to fully sort this list and show the steps:
42, 12, 34, 43, 9, 32, 2
42, 12, 34, 43, 9, 32, 2
42, 12, 34, 43 9, 32, 2,
42, 12 34, 43 9, 32 2,
42 12 34 43 9 32 2
12, 42 34, 43 9, 32 2,
12, 34, 42, 43 2, 9, 32,
2, 9, 12, 32, 34, 42,43
What is returned in the following code segment
public static void main(String[] args)
{
StringBuffer s = new StringBuffer("Aayan>");
string(s);
System.out.println(s);
}
public static void string(StringBuffer s){
s.append("Deven");
}
Aayan>Deven
What does this method do:
public static void something(ArrayList<String> list) {
for(int i = 0; i < list.size() / 2; i++) {
String temp = list.get(i);
list.set(i, list.get(list.size()-1-i));
list.set(list.size()-1-i, temp);
}
System.out.println(list);
}
This method reverses the content in the list
What is 17AC82 in Hexidecimal to Octal
5726202
The largest method is meant to find the largest value in a 2D array. Write a nested for each loop for this method so that the method works as intended.
public static int largest(int[][] nums){
int large = nums[0][0];
*MISSING CODE*
return large;
}
for (int[] row: nums)
for (int col: row)
if (col > large)
large = col;
Use quick sort to fully sort this list and show the steps:
13, 4, 23, 3, 45, 50, 5
13, 4, 23, 3, 45, 50, 5
3, 4, 23, 5, 45, 50, 13
3, 4, 5, 13, 45, 50, 23
3, 4, 5, 13, 23, 45, 50
3, 4, 5, 13, 23, 45, 50