Twa kɔ nsɛm atitiriw so
Log in
Sign up for FREE
arrow_back
Laabri

Semester Final AP Computer Science

star
star
star
star
star
Last updated over 2 years ago
41 Nsɛmmisa
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
Asemmisa {{asɛmmisaAhyɛnsode}}
1.

What is output by the code below?

int x = 10 % 3;

System.out.print( x );

Asemmisa {{asɛmmisaAhyɛnsode}}
2.

What is output by the code below?

int x = 10 / 3 ;

System.out.print( x );

Asemmisa {{asɛmmisaAhyɛnsode}}
3.

What is output by the code below?

int x = 5 / 2;

System.out.print( x );

Asemmisa {{asɛmmisaAhyɛnsode}}
4.

What is output by the code below?

double x = (double)5 / 2;

System.out.print( x );

Asemmisa {{asɛmmisaAhyɛnsode}}
5.

What is output by the code below?

System.out.print( 10 + 5 * 2);

Asemmisa {{asɛmmisaAhyɛnsode}}
6.

What is output by the code below?

System.out.print("a\tc" );

Asemmisa {{asɛmmisaAhyɛnsode}}
7.

What is output by the code below?

public static void main(String args[ ] )

{

}

Asemmisa {{asɛmmisaAhyɛnsode}}
8.

What is output by the code below?

String s = "123";

if(s.equals("123"))

out.println("true");

else

out.println("false");

Asemmisa {{asɛmmisaAhyɛnsode}}
9.

What is output by the code below?

String s = "abcdef";

out.println( s );

Asemmisa {{asɛmmisaAhyɛnsode}}
10.

In Java, every program statement ends with a what ?

Asemmisa {{asɛmmisaAhyɛnsode}}
11.

What is output by the code below?

Scanner s = new Scanner("a b cd e");

String result = "";

while( s.hasNext() )

{

result = result + s.next();

}

out.println(result);

Asemmisa {{asɛmmisaAhyɛnsode}}
12.

What is output by the code below?

int x = 0;

String w = "abcdefghixk";

for(x=w.length()-1; x>=0; x=x-2)

{

out.print(w.charAt(x));

}

Asemmisa {{asɛmmisaAhyɛnsode}}
13.

What is output by the code below?

for(int x=5; x < 20; x=x+3)

System.out.print(x + " ");

Asemmisa {{asɛmmisaAhyɛnsode}}
14.

What is output by the code below?

int x = 66;

if ( x == 67 )

System.out.print("67" );

else

System.out.println("!67");

Asemmisa {{asɛmmisaAhyɛnsode}}
15.

What is output by the code below?

System.out.println( 3 + " " + 3 );

Asemmisa {{asɛmmisaAhyɛnsode}}
16.

What is output by the code below?

System.out.println( 3 + 6 );

Asemmisa {{asɛmmisaAhyɛnsode}}
17.

What is the output?

System.out.println( "\"9" );

Asemmisa {{asɛmmisaAhyɛnsode}}
18.

Which of the following Scanner methods can be used to read in a int?

Asemmisa {{asɛmmisaAhyɛnsode}}
19.

Which of the following Scanner methods can be used to read in a double?

Asemmisa {{asɛmmisaAhyɛnsode}}
20.

Which of the following Scanner methods can be used to read in a String?

Asemmisa {{asɛmmisaAhyɛnsode}}
21.

What is output by the following code?

int total = 0;

for(int i=1; i <= 10; i=i+3)

for(int x=1; x <= i; x=x+2)

total = total + x;

out.println(total);

Asemmisa {{asɛmmisaAhyɛnsode}}
22.

What is output by the code below?

int x=9;

do{

x--;

}while(x>5);

out.println(x);

Asemmisa {{asɛmmisaAhyɛnsode}}
23.

What is output by the code below?

System.out.println( Math.sqrt(81) );

Asemmisa {{asɛmmisaAhyɛnsode}}
24.

What is output by the code below?

System.out.println( Math.floor(6.7) );

Asemmisa {{asɛmmisaAhyɛnsode}}
25.

What is output by the code below?

System.out.println( Math.ceil(6.7) );

Asemmisa {{asɛmmisaAhyɛnsode}}
26.

What is output by the code below?

System.out.println( Math.pow(3,3) );

Asemmisa {{asɛmmisaAhyɛnsode}}
27.

What is output by the code below?

String r = "abcdefghi";

out.println(r.charAt(3));

Asemmisa {{asɛmmisaAhyɛnsode}}
28.

What is output by the code below?

int s=0, x=0;

while(s<=10)

{

x += s % 2;

s=s+1;

}

System.out.println( x );

Asemmisa {{asɛmmisaAhyɛnsode}}
29.

What is output by the code below?

int t=1, amount=0;

do{

amount = amount + t;

t = t + 2;

}while(amount<20);

System.out.print(amount);

Asemmisa {{asɛmmisaAhyɛnsode}}
30.

What is output by the code below?

String u = "abcdefghi";

out.println(u.substring(3,5));

Asemmisa {{asɛmmisaAhyɛnsode}}
31.

What is output by the code below?

String v = "abcdefghi";

out.println(v.indexOf(‘d’));

Asemmisa {{asɛmmisaAhyɛnsode}}
32.

What is output by the code below?

String w = "abcdefghi";

out.println(w.indexOf(‘x’));

Asemmisa {{asɛmmisaAhyɛnsode}}
33.

What is output by the code below?

Scanner chop = new Scanner("1 2 3 4 5");

int x = 0;

while(chop.hasNextInt())

{

x += + chop.nextInt();

}

System.out.println( x );

Asemmisa {{asɛmmisaAhyɛnsode}}
34.

What is output by the code below?

Scanner chopper = new Scanner("a b c d e");

out.print(chopper.next());

out.print(chopper.next());

out.print(chopper.next());

Asemmisa {{asɛmmisaAhyɛnsode}}
35.

What is output by the code below?

String r = "abcdefghi";

System.out.println(r.substring(3,r.length()));

Asemmisa {{asɛmmisaAhyɛnsode}}
36.

What is output by the code below?

String r = "racecar";

System.out.println(r.lastIndexOf('a'));

Asemmisa {{asɛmmisaAhyɛnsode}}
37.

Which of the following can appear anywhere in a variable name

I. numbers

II. underscores

III. money signs

IV. alphabetic characters

Asemmisa {{asɛmmisaAhyɛnsode}}
38.

What is output by the code below?

public static int go2(int i)

{

int sum = 0;

for(int j = 0;j<i;j++)

sum+=j*2+1;

return sum;

}

////////////////////////////////////////////////////////////////////////////////////

//client code in the main of a runner class

System.out.println(go2(6));

Asemmisa {{asɛmmisaAhyɛnsode}}
39.

What is output by the code below?

int x = 3 % 10;

System.out.print( x );

Asemmisa {{asɛmmisaAhyɛnsode}}
40.

What is output by the code below?

double x = 5 / 2;

System.out.print( x );

Asemmisa {{asɛmmisaAhyɛnsode}}
41.

What is output by the code below?

System.out.print( 10 * 6 / 4);