Preskoči na glavni sadržaj
Prijava
Sign up for FREE
arrow_back
Biblioteka

Semester Final Review

star
star
star
star
star
Posljednje ažuriranje about 2 years ago
130
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
1
1
1
1
1
1
1
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
8.75
8.75
8.75
8.75
8.75
8.75
8.75
8.75
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
Pitanje 1
1.

What is the output by the code below?

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

Pitanje 2
2.

What is the ASCII value of a space?

Pitanje 3
3.

Which of the following would print one backslash on the screen if used in a print( ) or println( )?

Pitanje 4
4.

What is output by the following code?

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

Pitanje 5
5.

What is the output by the code below?

System.out.println("Hello ");

System.out.print("people ");

System.out.println("everywhere ");

Pitanje 6
6.

What is output by the following code?

System.out.println(3+4+""+5*3);

Pitanje 7
7.

What is the output by the code below?

int num = 5;

System.out.println("num");

Pitanje 8
8.

What is the output by the code below?

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

Pitanje 9
9.

What is the output by the code below?

char c = 65;

System.out.println(c);

Pitanje 10
10.

Which of the following lines correctly defines a char variable?

Pitanje 11
11.

Which of the following can be used to comment code in Java?

Pitanje 12
12.

Which of the following is the tab character?

Pitanje 13
13.

Which of the following lines correctly defines a String variable?

Pitanje 14
14.

What of the following is not a legal reserved word for a java data type?

Pitanje 15
15.

What is the output by the code below?

int cost = 2.65;

System.out.println("Price: " + cost);

Pitanje 16
16.

What is the output by the code below?

String s = "aplus";

System.out.println( s );

Pitanje 17
17.

In Java, every program statement ends with a what ?

Pitanje 18
18.

Every method must have an open and close what?

Pitanje 19
19.

What is the output by the code below?

System.out.print( "ap\\lus" );

Pitanje 20
20.

Which of the following is a 32 bit data type?

Pitanje 21
21.

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

Pitanje 22
22.

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

Pitanje 23
23.

Which of the following Scanner methods can be used to read in the value “apluscompsciisthebest” ?

Pitanje 24
24.

Given the following statement, var must be defined as which of the following types?

var=keyboard.nextFloat();

Pitanje 25
25.

Given the following statement, var must be defined as which of the following types?

var=keyboard.nextLine();

Pitanje 26
26.

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

Pitanje 27
27.

Given the following statement, var must be defined as which of the following types?

var=keyboard.nextLong();

Pitanje 28
28.

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

Pitanje 29
29.

Which of the following is the Java class used for input?

Pitanje 30
30.

Which of the following is used in the Scanner constructor to connect to the keyboard?

Pitanje 31
31.

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

Pitanje 32
32.

Which of the following Scanner methods can be used to read in an integer?

Pitanje 33
33.

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

Pitanje 34
34.

Which of the following Scanner methods can be used to read in the value

”apluscompsci is the best” ?

Pitanje 35
35.

Which of the following would correctly define and instantiate a Scanner?

Pitanje 36
36.

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

Pitanje 37
37.

Given the following statement, var must be defined as which of the following types?

var=keyboard.next();

Pitanje 38
38.

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

Pitanje 39
39.

Given the following statement, var must be defined as which of the following types?

var=keyboard.nextByte();

Pitanje 40
40.

Given the following statement, var must be defined as which of the following types?

var=keyboard.nextDouble();

Pitanje 41
41.

What is output by the code below?

double x = .5 + .5;

System.out.print(x);

Pitanje 42
42.

What is output by the code below?

int x = 1;

x *= 5;

System.out.print(x);

Pitanje 43
43.

What is output by the code below?

System.out.print( 4 - 3 );

Pitanje 44
44.

What is output by the code below?

System.out.print(4 % 3);

Pitanje 45
45.

What is output by the code below?

System.out.print( (int)9.6 );

Pitanje 46
46.

What is output by the code below?

int x = 12,

y = 20;

int z = x + y;

double a = z;

System.out.print(a);

Pitanje 47
47.

What is output by the code below?

System.out.println( 7 / 0);

Pitanje 48
48.

What is output by the code below?

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

Pitanje 49
49.

What is output by the code below?

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

Pitanje 50
50.

What is output by the code below?

System.out.println( Math.pow(6,2) );

Pitanje 51
51.

What is output by the code below?

System.out.println( (int)Math.pow( Math.sqrt(60),2) );

Pitanje 52
52.

What is output by the code below?

System.out.println( Math.pow( Math.sqrt(25),2) );

Pitanje 53
53.

What is output by the code below?

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

Pitanje 54
54.

What is output by the code below?

System.out.println( Math.max(26,18) );

Pitanje 55
55.

What is output by the code below?

System.out.println( Math.min(36,8) );

Pitanje 56
56.

What is output by the code below?

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

Pitanje 57
57.

What is output by the code below?

public class Fun

{

public int times(int num1, int num2)

{

return num1 * num2;

}

}

Fun aplus = new Fun();

System.out.println( aplus.times( 8, 6 ) );

Pitanje 58
58.

What is output by the code below?

public class Fun

{

public int times(int num1, int num2)

{

return num1 + num2;

}

}

Fun aplus = new Fun();

System.out.println( aplus.times( 23, 13 ) );

Pitanje 59
59.

What is output by the code below?

public class Fun2

{

public static int times(int num1, int num2)

{

return num1 * num2;

}

}

System.out.println( Fun2.times(6 , 7) );

Pitanje 60
60.

What is output by the code below?

public class Fun2

{

public static int times(int num1, int num2)

{

return num1 + num2;

}

}

System.out.println( Fun2.times(5 , 5) );

Pitanje 61
61.

How many methods does Bird contain?

public class Bird

{

public void speak()

{

out.println("chirp-chirp");

}

public void sayName()

{

out.println("baby bird");

}

}

Pitanje 62
62.

How many return methods does Bird contain?

public class Bird

{

public void speak()

{

out.println("chirp-chirp");

}

public void sayName()

{

out.println("baby bird");

}

}

Pitanje 63
63.

What is output by the code below?

public class Test

{

public void go()

{

out.print("A");

}

public void fun()

{

out.print("B");

}

}

Test x = new Test();

x.go();

Pitanje 64
64.

What is output by the code below?

public class Test

{

public void go()

{

out.print("A");

}

public void fun()

{

out.print("B");

}

}

Test x = new Test();

x.go();

x.go();

x.go();

Pitanje 65
65.

What is output by the code below?

public class Test

{

public void go()

{

out.print("A");

fun();

}

public void fun()

{

out.print("B");

}

}

Test x = new Test();

x.fun();

x.go();

Pitanje 66
66.

What is output by the code below?

public class Test

{

public void go()

{

out.print("A");

}

public void fun()

{

out.print("B");

go();

}

}

Test x = new Test();

x.go();

x.fun();

x.fun();

Pitanje 67
67.

What is output by the code below?

public class Test

{

public void go()

{

out.print("A");

stop();

}

public void fun()

{

out.print("B");

go();

}

public void stop()

{

out.print("C");

}

}

Test x = new Test();

x.fun();

Pitanje 68
68.

What is output by the code below?

String s = "apluscompsci";

System.out.println( s.substring(4,5) );

Pitanje 69
69.

What is output by the code below?

String s = "apluscompsci";

System.out.println( s.substring( s.length()-1 ) );

Pitanje 70
70.

What is output by the code below?

String s = "apluscompsci";

System.out.println( s.charAt( s.length()-3 ) );

Pitanje 71
71.

What is output by the code below?

String s = "apluscompsci";

System.out.println( s.charAt(0) );

Pitanje 72
72.

What is output by the code below?

String s = "apluscompsci";

System.out.println( s.charAt(5) );

Pitanje 73
73.

What is output by the code below?

String s = "apluscompsci";

System.out.println( s.indexOf( "s" ) );

Pitanje 74
74.

What is output by the code below?

String s = "apluscompsci";

System.out.println( s.indexOf( "apluscomp" ) );

Pitanje 75
75.

What is output by the code below?

String s = "ishouldofstudied";

System.out.println( s.length() );

Pitanje 76
76.

What is output by the code below?

String s = "apluscompsci";

System.out.println( s.substring( 6 ) );

Pitanje 77
77.

What is output by the code below?

String s = "apluscompsci";

System.out.println( s.indexOf( "b" ) );

Pitanje 78
78.

What is output by the code below?

String s = "apluscompsci";

int x = s.indexOf( "c" );

System.out.println( s.substring( x ) );

Pitanje 79
79.

What is output by the code below?

int x = "alligator".length() - "crocodile".length();

System.out.println( x );

Pitanje 80
80.

What is output by the code below?

int x = "crocodile".length() - "croc".length();

System.out.println( x );

Pitanje 81
81.

What is output by the code below?

String s = "apluscompsci";

System.out.println( s.substring(0,2) );

Pitanje 82
82.

What is output by the code below?

String s = "apluscompsci";

int x = 3;

System.out.println( s.substring(x,x+1) );

Pitanje 83
83.

What is output by the code below?

String s = "dog";

String r = "dog ";

System.out.println( s.equals( r ) );

Pitanje 84
84.

What is output by the code below?

String s = "dog ";

String r = new String("dog");

System.out.println( s.equals( r ) );

Pitanje 85
85.

What is output by the code below?

String s = "dog";

String r = new String("dog");

System.out.println( s != r );

Pitanje 86
86.

What is output by the code below?

String s = "dog";

String r = "dog";

r = s;

s = null;

System.out.println( r );

Pitanje 87
87.

What is output by the code below?

String s = "dog";

String r = s;

s = null;

System.out.println( s );

Pitanje 88
88.

What is output by the code below?

String s = "Big dog";

String r = "A dog";

System.out.println( s.compareTo(r) );

Pitanje 89
89.

What is output by the code below?

String s = "dog";

String r = "cog";

System.out.println( r.compareTo(s) );

Pitanje 90
90.

What is output by the code below?

String s = "dodge";

String r = "cloths";

System.out.println( s.compareTo(r) );

Pitanje 91
91.

What is output by the code below?

String s = "bob";

String r = "bod";

System.out.println( s.compareTo(r) );

Pitanje 92
92.

What is output by the code below?

String s = 12;

int x = Integer.parseInt( s );

System.out.println( x + 3 );

Pitanje 93
93.

What is output by the code below?

String s = "12.7";

Double x = Double.parseDouble( s );

System.out.println( x + 3 );

Pitanje 94
94.

What is output by the code below?

String s = "12.7";

double x = Double.parseDouble( s );

System.out.println( x + 3 );

Pitanje 95
95.

What is output by the code below?

String s = "12";

int x = Integer.parseInt( s );

System.out.println( s + x + 3 );

Pitanje 96
96.

What is output by the code below?

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

Pitanje 97
97.

What is returned by the call myst("aplus","aplus")?

public boolean myst(String a, String b)

{

return a.equals( b );

}

Pitanje 98
98.

What is returned by the call myst("aplus","aplus")?

public boolean myst(String a, String b)

{

return a == b;

}

Pitanje 99
99.

What is returned by the call myst("ana","banana")?

public boolean myst(String a, String b)

{

return b.lastIndexOf(a)!=b.indexOf(a);

}

Pitanje 100
100.

What is the purpose of myst?

public boolean myst(String a, String b)

{

return b.lastIndexOf(a)!=b.indexOf(a);

}

Pitanje 101
101.

What is returned by the call go(60,78)?

public static String go(int x, int z)

{

String s = "xyz";

if(z > 60)

{

s += "def";

}

if(x <= 60)

s += "ghi";

return s;

}

Pitanje 102
102.

Consider the following code segment.

String s = "red ball";

if(s.indexOf("a")>0)

s = s + " zed";

if(s.indexOf("z")>0)

s = "alpha " + s;

out.println(s);

What will be printed as a result of executing the code segment?

Pitanje 103
103.

Consider the following code segment.

String s = "abac-adae-bfbg-bhbi";

int index = s.indexOf("b");

if(index > 0)

out.println(s.substring(index));

What will be printed as a result of executing the code segment?

Pitanje 104
104.

What is returned by the call go(7) ?

public static int go( int a )

{

int ans = 0;

if(a>=7)

{

ans += 1;

}

ans += 2;

return ans;

}

Pitanje 105
105.

What is output by the code below?

String a = "1";

String b = new String("1");

if( a == b )

{

System.out.print( "up" );

}

if( a.equals(b) )

{

System.out.print( "on" );

}

System.out.print( "at" );

Pitanje 106
106.

Consider the following code segment.

double x = 19.8;

int y = 0;

if( x > 5 )

y += 5;

if( x > 10 )

y += 10;

if( x > 15 )

y += 15;

out.print( y );

What will be printed as a result of executing the code segment?

Pitanje 107
107.

Consider the following code segment.

String s = "even";

if(s.indexOf("a")>0)

s = s + " zed";

if(s.indexOf("v")>0)

s = "alpha " + s;

out.println(s);

What will be printed as a result of executing the code segment?

Pitanje 108
108.

Consider the following code segment.

String s = "apple";

if(s.indexOf("a")>0)

s = s + " zed";

if(s.indexOf("l")>0)

s = "alpha " + s;

out.println(s);

Pitanje 109
109.

What is output by the code below?

int b = 100;

if( b > 100)

out.print("go");

else if( b > 90)

out.print("it");

else

out.print("up");

out.print("on");

Pitanje 110
110.

What is output by the code below?

int a = 75, b = 100;

if( a > 90)

if( b > 100)

out.print("go");

else if( b > 90)

out.print("it");

else

out.print("up");

out.print("on");

Pitanje 111
111.

What is output by the code below?

int a = 105, b = 120;

if( a > 90)

if( b > 100)

out.print("go");

else if( b > 90)

out.print("it");

else

out.print("up");

out.print("on");

Pitanje 112
112.

What is output by the code below?

int a = 105, b = 40;

if( a > 90)

if( b > 100)

out.print("go");

else if( b > 90)

out.print("it");

else

out.print("up");

out.print("on");

Pitanje 113
113.

What values will be stored in c and d after execution of the following program segment?

int c = 5, d = 10;

if(d>c){

if(c > 50)

c /= 2;

else

c = d-c;

d = d/5;

}

else{

c = c/2;

d = d/2+3;

}

Pitanje 114
114.

What values will be stored in c and d after execution of the following program segment?

int c = 12, d = 3;

if(d>c){

if(c > 50)

c /= 2;

else

c = d-c;

d = d/5;

}

else{

c = c/2;

d = d/2+3;

}

Pitanje 115
115.

What is output by the code below?

int j = 11/2;

switch(j)

{

case 5:j++;break;

case 6:j++;break;

case 7:j++;break;

}

System.out.println(j);

Pitanje 116
116.

What is output by the code below?

int x= 11;

switch( x )

{

case 11 : System.out.print("it");

case 21 : System.out.print("go");

case 98 : System.out.print("up"); break;

}

Pitanje 117
117.

What is output by the code below?

int b = 110;

if( b > 100)

out.print("go");

else if( b > 90)

out.print("it");

else

out.print("up");

out.print("on");

Pitanje 118
118.

What is output by the code below?

int b = -5;

if( b > 100)

out.print("go");

else if( b > 90)

out.print("it");

else

out.print("up");

out.print("on");

Pitanje 119
119.

What is output by the code below?

for(int i=0; i<=10; i=i+2)

out.print(i);

Pitanje 120
120.

What is output by the code below?

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

out.print(i);

Pitanje 121
121.

What is output by the code below?

for(int i=15; i>2; i=i-2)

System.out.print(i);

Pitanje 122
122.

What is output by the code below?

int ans = 0;

for(int i=10; i>-1; i=i-2)

ans += i;

System.out.print( ans );

Pitanje 123
123.

What is output by the code below?

int ans = 0;

for(int i=0; i<12; i=i+3)

ans += i;

System.out.print( ans );

Pitanje 124
124.

What is output by the code below?

int ans = 0;

for(int i=0; i<20; i=i+3)

if( i % 2 == 0 )

ans += i;

System.out.print( ans );

Pitanje 125
125.

What is returned by the call go( 7 ) ?

public static String go( int x)

{

String s = "";

for(int n = x; n > 0; n = n - 2)

s = s + n + " ";

return s;

}

Pitanje 126
126.

What is returned by the call go( 17 ) ?

public static int go( int x)

{

int val = 0;

for(int n = 1; n < x; n = n + 4)

val = val + n;

return val;

}

Pitanje 127
127.

What is returned by the call go( 7, 12 ) ?

public static int go( int x, int y)

{

int cnt = 0;

for(int n = x; n < y; n = n + 1)

if(n % 2 != 0 )

cnt++;

return cnt;

}

Pitanje 128
128.

int tot = 0;

for( int i=2; i<17; i++ ) {

tot = tot + i;

}

out.println( tot );

Pitanje 129
129.

int count=0;

for(int j=4; j<23; j++) {

if(j%2==1)

count++;

}

out.println( count );

Pitanje 130
130.

int sum=0;

for(int m=5; m<18; m++) {

if(m%2!=1)

sum=sum+m;

}

out.println(sum);