Questão 1
Questão
System.out.println or next.Int( ) or close( ) are examples of:
Responda
-
syntax
-
variable
-
method
-
object
Questão 2
Questão
In the following sample code, how do you best describe the "Scanner":
public class squares {
public static void main(String[] args) {
java.util.Scanner scanner = new java.util.Scanner(System.in);
int num = 0;
System.out.print("Please enter a number: ");
num = scanner.nextInt();
scanner.close();
Responda
-
statement
-
method
-
object
-
argument
Questão 3
Questão
In the sample code below, what best describes num ?
public static void main(String[] args) {
java.util.Scanner scanner = new java.util.Scanner(System.in);
int num = 0;
int result = 0;
System.out.print("Please enter a number: ");
num = scanner.nextInt();
result = num * num;
scanner.close();
}
}
Responda
-
string
-
statement
-
variable
-
object
Questão 4
Questão
All is (are) true of pseudocode except:
Responda
-
comments that are understood by people
-
recognized by the compiler
-
a tool programmers use when creating a model of the program
Questão 5
Questão
string literals.
– char literals are enclosed in [blank_start]single[blank_end] quotes.
- [blank_start]String[blank_end] literals are enclosed in double quotes
Questão 6
Questão
How do you assign a variable?
Questão 7
Questão
This program asks to simply input a word or "string" and the output is the first character of the word (so an input of agents, the program's output is "a")
java.util.Scanner scanner = [blank_start]new java.util.Scanner(System.in);[blank_end]
[blank_start]System.out.print[blank_end]("Enter a character: ");
char inputChar = [blank_start]scanner.next().charAt(0);[blank_end]
System.out.println("You have entered: "+inputChar);
[blank_start]scanner.close();[blank_end]
Questão 8
Questão
What is wrong with the following code:
System.out.println("The quick brown fox" + "jumped over the \n" "slow moving hen.");
Responda
-
there are extra " " between \n and slow
-
use of the "+" is not correct
-
nothing is wrong with the code and should print "jump over the \n slow moving hen
Questão 9
Questão
which is NOT a valid statement
Responda
-
*/comment 3/*
-
//comment 1
-
/**comment 4*/
Questão 10
Questão
Which of the following will fix the code below:
final int x = 22, y = 4;
y += x;
System.out.println("x = " + x + ", y = " + y);
Responda
-
change y+=x; to y = y + x
-
remove "final" because this makes the "int x" a constant
-
nothing is wrong with the code
Questão 11
Questão
How can you output quotation marks around green ("green") in the System.out.println() method:
Responda
-
System.out.println("\green\")
-
System.out.println(\"green\")
-
System.out.println(\\"green"\\)
Questão 12
Questão
In the JAVA language, fill in what best coincides with the given term
Classes: [blank_start]PascalCase[blank_end]
[blank_start]Methods/Variables[blank_end]: camelCase
[blank_start]Constants[blank_end]: CAPS_UNDERSCORE
Responda
-
PascalCase
-
Methods/Variables
-
Constants
Questão 13
Questão
How do you define a method?
Responda
-
public.java.util.scanner = scanner()
-
public returnType methodName(arg1Type, arg2Type,...) {
}
-
import java util.*;
Questão 14
Questão
In the following code, System.out.println(num) is an example of:
double num = 5.4;
System.out.println(num);
num = 0.0;
Responda
-
class method
-
value returning method
-
void method
Questão 15
Questão
If method A calls method B, and method B calls method C, and method C calls method D, when method D finishes, what happens?
Responda
-
the program terminates
-
control is returned to C
-
control is returned to A
Questão 16
Questão
When an argument is passed to a method:
Responda
-
values may not be passed to the method
-
its value is copied into the method's parameter variable
-
its value may not be changed within the call method
Questão 17
Questão
In the following code, Integer.parseInt(str), is an example of:
int num;
string str = "555";
num = Integer.parseInt(str) + 5;
Responda
-
void method
-
value returning method
-
complex method
Questão 18
Questão
If chr is a character variable, which of the following if statements is written correctly?
Responda
-
if(char = 'a')
-
if (char == 'a')
-
If(char=="a")
Questão 19
Questão
[blank_start]Short-circuit evaluation[blank_end] works like this: If the expression on the left side of the && operator is false, the expression the right side will not be checked.
Questão 20
Questão
To do a case insensitive compare which of the following could be used to test the equality of two strings, str1 and str2?
Questão 21
Questão
What would be the value of x after the following statements were executed?
int x = 10;
switch (x)
{
case 10:
x += 15;
case 12:
x -= 5;
break;
default:
x *= 3;
}
Questão 22
Questão
What will be displayed to the screen with the following statements?
System.out.print("$%,.4f", 4452.34246);
Questão 23
Questão
What will be the value of x after the following code is executed? If the code has any kind of syntax error, please type in the answer “error”.
int x = 10
if (x>5) {
x /= 10;
}
if (x<5) {
x += 5;
}
if (x > 10) {
x -=4;
}
else {
x+=4;
}
Questão 24
Questão
An if statement's alternative path is implemented with _______.
Questão 25
Questão
The part of a method that is a collection of statements that are performed when the method is executed is called the method _______.
Questão 26
Questão
When a primitive data type argument is passed to a method, it is passed by _______.
Questão 27
Questão
When an object, such as a String, is passed as an argument, it is passed by
Questão 28
Questão
What will be the values of x and y as a result of the following code?
int x = 25, y = 8;
x += y++;
Responda
-
x = 33; y = 9
-
x=34; y = 9
Questão 29
Questão
What will be printed after the following code is executed?
for (int number = 5; number <= 15; number +=3)
System.out.print(number + ", ");
Responda
-
5, 8, 11, 14, 17
-
5, 8, 11, 14
Questão 30
Questão
UML diagrams does contain
Questão 31
Questão
Unified Modeling Language which is used in object oriented software engineering.
Questão 32
Questão
You should not define a class field that is dependent upon the values of other class fields:
Questão 33
Questão
Instance methods do not have this key word in their headers:
Questão 34
Questão
It is common practice to use a ________ variable as a size declarator
Questão 35
Questão
What will be the value of x[8] after the following code has been executed?
final int SUB = 12;
int[] x = new int[SUB];
int y = 100;
for(int i = 0; i < SUB; i++)
{
x[i] = y;
y += 10;
}
Questão 36
Questão
Java performs ________, which means that it does not allow a statement to use a subscript that is outside the range of valid subscripts for the array.
Responda
-
array bounds checking
-
scope resolution binding
Questão 37
Questão
What will be the results of the following code?
final int ARRAY_SIZE = 5;
double[] x = new double[ARRAY_SIZE];
for(int i = 1; i <= ARRAY_SIZE; i++)
{
x[i] = 10.0;
}
Questão 38
Questão
What would be the results of the following code?
int[] x = { 55, 33, 88, 22, 99,
11, 44, 66, 77 };
int a = 10;
if(x[2] > x[5])
a = 5;
else
a = 8;
Questão 39
Questão
What would be the results of the following code?
int[] array1 = new int[25];
… // Code that will put values in array1
int value = array1[0];
for (int a = 1; a < array1.length; a++)
{
if (array1[a] < value)
value = array1[a];
}
Questão 40
Questão
What do you normally use with a partially-filled array?
Questão 41
Questão
To return an array of long values from a method, use this as the return type for the method.
Questão 42
Questão
In order to do a binary search on an array:
Questão 43
Questão
What is the value of scores[2][3] in the following array?
int [] [] scores = { {88, 80, 79, 92}, {75, 84, 93, 80},
{98, 95, 92, 94}, {91, 84, 88, 96} };
Questão 44
Questão
The part of a method that is a collection of statements that are performed when the method is executed is called
Questão 45
Questão
An array has a/an __________ size
Questão 46
Questão
An ArrayList has a fixed or dynamic size
Questão 47
Questão
When trying to access an element of an array, Java performs array _____ checking to make sure the subscript of the element exists
Questão 48
Questão
Given an array variable with the name kiwi, what is the code to get the amount of elements in kiwi?
Questão 49
Questão
Given an ArrayList variable with the name kiwi, what is the code to get the amount of elements in kiwi?
Questão 50
Questão
Given a String variable with the name kiwi, what is the code to get the amount of characters in kiwi?
Responda
-
kiwi.length();
-
kiwi.size();
Questão 51
Questão
Classes have _______ which store data
Questão 52
Questão
What is the term used for the character that separates tokens?
Questão 53
Questão
What will be the value of x after the following code is executed?
int x, y = 2, z = 3;
x = (++y)*(++z);
Questão 54
Questão
How many times will the following do-while loop be executed?
int x = 5;
do
{ x*=2;} while (x > 10)
Questão 55
Questão
What will be the value of x after the following code is executed? If the code has any kind of syntax error, please type in the answer "error".
int x = 1;
while (x++ < 10) {
x++;
}
Questão 56
Questão
How many times will the following for loop be executed?
for (int count = 1; count <= 7; count += 3) {System.out.println("Java is great!!!");}
Questão 57
Questão
What will the following code output to the console?
int [ ] integers = new int [5];
System.out.println(integers[0]);
Questão 58
Questão
What will the following code output to the console?
ArrayList<Integer> integers = new ArrayList<>(5);
System.out.println(integers.get(0));
Questão 59
Questão
What is the output?
ArrayList<Integer> integers = new ArrayList<>();
integers.add(5);
integers.add(7);
integers.add(1,18);
integers.remove(0);
System.out.println(integers.get(0));
Questão 60
Questão
What's the output?
ArrayList<String> strings = new ArrayList<>();
strings.add("hi");
strings.add("bye");
strings.add("howdy");
strings.remove(0);
System.out.println(strings.get(2));
Questão 61
Questão
What is the output?
int[ ] integers = {1,2,3,4,5};
for (int i = 0; i< integers.length; i++) {
integers [i]++;
}
System.out.println(integers[3]);
Questão 62
Questão
What is the output?
int[]integers = new int[10];
final int AMOUNT_OF_RUNS = 20;
final int ADD_ME = 5;
for (int i = 0; i < AMOUNT_OF_RUNS; i++) {
integers[i] += ADD_ME;
}
System.out.println(integers[3]);
Questão 63
Questão
What is the output?
int [ ] integers = new int [10];
final int ADD_ME = 5;
for (int i = 0; i< integers.length; i++) {
integers [i] += ADD_ME*1;
}
System.out.println(integers[4]);
Questão 64
Questão
What is the output?
int [ ] [ ] integers = { { 14, 5, 21}, {34, 54}, {3, 6, 7}};
int total = 0;
for (int row = 0; row<integers.length; row++) {
for (int col = 0; col<integers[0].length; col++) {
total += integers[row][col];
}
}
System.out.println(total);
Questão 65
Questão
What is the output?
int [ ] [ ] integers = { { 14, 5, 21}, {34, 54}, {3, 6, 7}};
int mysteryVariable = 0;
for (int row = 0; row<integers.length; row++) {
for (int col = 0; col<integers[row].length; col++) {
mysteryVariable++;
}
}
System.out.println(mysteryVariable);
Questão 66
Questão
what is the output?
int [] [] integers = {{14,5,21{, {34, 54}, {3,6,7}};
int mysteryVariableOne = integers [0][0];
int mysteryVariableTwo = integers [0][0];
for (int row = 0; row < integers.length; row++) {
for (int col = 0; col <integes[row].length; col++) {
if (mysteryVariableOne < integers[row][col]) {
mysteryVariableOne = integers[row][col];
}
if (mysteryVariableTwo> integers[row][col]) {
mysterVariableTwo = integers[row][col];
}}}
System.out.println(myseryVariableOne - mysteryVariableTwo);
Questão 67
Questão
Output?
static ArrayList<String> listOfStrings;
public static void main (String[ ] args) {
String [ ] strings = {"D", "Z", "G", "P", "M" };
for (String s : strings)
listOfStrings.add(s);
System.out.println(listOfStrings.get(2));
}
Questão 68
Questão
Output?
static ArrayList<String> listOfStrings;
public static void main (String[ ] args) {
String [ ] strings = {"D", "Z", "G", "P", "M" };
ArrayList<String> listOfStrings = new ArrayList<>();
for (int i = strings.length-1; i>0; i--) {
listOfStrings.add(strings[i] + strings[i-1]);
System.out.println(listOfStrings.get(2));