1/49
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
word_count is a legal identifier in java
true
k2 is a legal identifier in java
true
Krazy1 is a legal identifier in java
true
hot? is a legal identifier in java
false
2ndPlaceWinnder is a legal identifier in java
true
2beOrNot2Be is a legal identifier in java
true
cous-cous is a legal identifier in java
false
its legal to have an integer variable named x and another integer variable named X in the same program
true

what is the result of:
compiler error: can’t find symbol z
the most important job of the java compiler is to
to translate high-level languages (readable to humans) into lower-level languages (readable to computers)
what is the type of the expression ‘1’?
character
what is the type of the expression 23.2?
double
what is the type of the expression 32 + 2
integer
what is the type of the expression “32” + 2
string
what is the result of the expression 52482/24478198
0
what is the result of the expression: (true || (3 == 2))
true
what is the result of the expression: (!(4 < 2) && 3 < 10)
true
what is the result of the expression 2/5 ! = 2/5.0
false
what is the result of the expression !((true || 3 < 2 && !(false || true))
true
what is the result of the expression 18 % 5 × 10 + 3 × 4 / 2
36
what is the result of the expression: 2 % 5 × 4 + 3 × 5/2
15
what is the result of the expression 0 * (1264 + 2835) - 1.0
-1.0
what is the result of the expression 5+3%6/2+8×5/3
19
what is the result of the expression 3 > 3%5 + 2 || 5 < 7 && 1 < 2
true
what is the result of the expression 3 > 3 % 5 + 2 && 5 < 7 && 1 > 2 % 2
false
what is the result of the expression 2+1+”.”+(3/4)+3×4
3.012
what is the result of the expression “1”+5/2+3%4×5+(6+7)
121513
what is the result of the expression: “ascend”.charAt(1) + “acknowledge”.substring(3,6)
snow
turn into a java expression the statement “x is a multiple of y”
(x % y == 0)
write an if/else statement that prints “in the black” if revenue is the same or higher than expenses, otherwise print out “in the red”
if (revenue >= expenses) {
System.out.print(“in the black”);
} else {
System.out.print(“in the red”);
}
what is the output of the following code:
for (int i = 0; i < 10; i++) {
if (i % 3 == 1) {
System.out.print(i);
}
{
1 4 7
what is the output of this code:
for (int i = 0; i < 3; i++) {
for (int j = 0; j <= i; j++) {
System.out.print(i + j);
System.out.print(“ “);
}
System.out.print();
}
0
1 2
2 3 4
what is the output of this code?
public class Presidents {
public static void main(String args[]) {
int x = 10, y = 20, z = 30;
if (x<y) {
System.out.print(“Washington”);
} else if ((x+y) % 2 == 0) {
System.out.print(“Adams”);
} else if (z-2 < y+1) {
System.out.print(“Jefferson”);
} else {
System.out.print(“Madison”);
}
}
}
Washington
public class Presidents {
public static void main(String args[]) {
int x = 10, y = 20, z=30;
if (x<y) {
System.out.print(“Washington”);
} if ((x + y) % 2 == 0) {
System.out.print(“Adams”);
} else if (z-2 < y+1) {
System.out.print(“Jefferson”);
} else {
System.out.print(“Madison”);
}
}
}
Washington
Adams
what is the output of this code??
public static void main(String args[]) {
int x = 10, y = 20, z = 30;
if (x<y) {
System.out.print(“Washington”);
} else if ((x+y) % 2 == 0) {
if (z >= 30 || z <= 30) {
System.out.print(“(not Quincy) “);
}
System.out.print(“Adams”);
} else if (z-2 < y+1) {
System.out.print(“Jefferson”);
} else {
System.out.print(“Madison”);
}
}
Washington
what is the output of this code?
public static void main(String args[]) {
int x = 10, y = 20, z = 30;
if (x<y) {
System.out.print(“Washington”);
} if ((x+y) % 2 == 0) {
System.out.print(“Adams”);
} else if (z-2 < y+1) {
System.out.print(“Jefferson”);
} else {
if (x == 10) {
System.out.print(“Madison”);
} else {
System.out.print(“Monroe”);
}
}
}
Washington
Adams
what is the value of a, b, and c when the following code finishes?
int a = 5, b = 3 c =2;
if (c < a) {
c -= a;
} else if (b < a) {
b -= a';
}
if (a + b > c) {
a += 10;
} else {
b+= 10;
}
a = 15
b = 3
c = -3
what is the value of a, b, and c when the following code finishes?
int a = 1, b = 2, c = 3;
if (a *2 < b) {
a*=3;
c-=b;
}
if (b < a) {
b++;
} else {
a—;
c++;
}
a = 0
b = 2
c = 4
what is printed by the following?:
for (int i =1; i<4; i++) {
for (char c = ‘a’; c <= ‘c’; c++) {
if (i %2 == 0) {
i++;
System.out.print(i + “ “ + c)';
} else {
c++;
System.out.print(c + “ “ + i);
}
}
}
b 1
d 1
3 a
c 3
what is printed by the following?
String s1 = “bob”;
String s2 = “lob”;
String s3 = “law”;
for (int i = 0; i < 4; i++) {
if (i %2 == 0) {
s1 +=s2;
} else {
s2 = s1 + s3;
}
}
System.out.print(s1);
boblobbobloblaw
is there a compiler error in this code? if so, what is it? if not, whats printed?
public class WhatsPrinted1 {
public static void func(int x) {
x++;
}
public static void main(String args[]) {
int y = 10;
func(y);
System.out.print(y);
}
}
no error, 10
is there a compiler error in this code? if so what is it? if not, whats printed
public class WhatsPrinted1 {
public static void func(int x) {
x++;
System.out.print(x);
}
public static void main(String args[]) {
int y = 10;
func(y);
}
}
no error, 11 is printed
is there a compiler error in this code? if so, what is it if not, whats printed?
public static WhatsPrinted {
public static void func(int x, int, y, int z) {
x++;
y += z %2;
z *= 2;
}
public static void main (String args[]) {
int x = 10, y = 20, z = 30;
func(y, z, x);
System.out.print(x);
}
}
no error
10 is printed because only x is printed not the function result
is there a compiler error in this code? if so, what is it? if not whats printed?
public class WhatsPrinted4 {
public static void func(int x, int y, int z) {
x++;
y += z%2;
z *= 2;
System.out.print(z);
}
public static void main(String args[]) {
int x = 10, y = 20, z = 30;
func(y, z, x);
}
}
no error, 20 is printed
is there a compiler error in this code? if so, what is it? if not, whats printed?
public class WhatsPrinted {
public static int func(int x) {
x *= 2;
return x;
}
public static void main(String args[]) {
int x = 10;
func(x);
System.out.print(x);
}
}
no error, 10 because it did not print the function result
is there a compiler error in this code? if so what is it? if not what’s printed?
public class WhatsPrinted {
public static int func(int x) {
x *= 2;
return x;
}
public static void main(String args[]) {
int x = 10;
x = func(x);
System.out.print(x);
}
}
no error, 20
is there a compiler error in this code? if so, what is it? if not, what’s printed?
public class WhatsPrinted {
public static void func(String base, String prefix, String suffix) {
base = prefix + base + suffix;
}
public static void main(String args[]) {
String r = “ject”;
String p = “con'“;
String s = “ure”;
func(r, p, s);
System.out.print(r );
}
}
no error, “ject”
is there a compiler error in this code? if so, what is it? if not, what’s printed?
public class WhatsPrinted {
public static void func(String base, String prefix, String suffix) {
base = prefix + base + suffix;
return base;
}
public static void main(String args[]) {
String r = “ject”;
String p = “con'“;
String s = “ure”;
func(r, p, s);
System.out.print(r );
}
}
no error, “ject”
is there a compiler error in this code? if so, what is it? if not, what’s printed?
public class WhatsPrinted {
public static void func(String base, String prefix, String suffix) {
base = prefix + base + suffix;
return base;
}
public static void main(String args[]) {
String r = “ject”;
String p = “con'“;
String s = “ure”;
r = func(r, p, s);
System.out.print(r );
}
}
no error, “conjecture“
is there a compiler error in this code? if so, what is it? if not, what’s printed?
public class WhatPrinted {
public static void f1() {
System.out.print(“a”);
}
public static void f2() {
f1();
System.out.print(“b”);
}
public static void f3() {
f2();
f1();
System.out.print(“c”);
}
public static void main(String args[]) {
f3();
System.out.print();
}
}
no error, abac