stud
bud
Sign up
Log in
Home
Library
Explore
SAT
More
COMP1000 Revision Flashcards | StudBud
Explore
/
COMP1000 Revision
COMP1000 Revision
20 terms
·
StudBud Administration
·
245 plays
revision of basic programming concepts
Flashcards
20 cards
F
Practice quiz
P
Host live
L
Questions
20
Answers
1
Which of the following gives the last digit of an integer val?
val/10
val%10
val-10
val+10
2
What is the header of a function that returns the average of two integers?
float average(float a, float b)
int average(float a, float b)
float average(int a, int b)
int average(int a, int b)
3
If an array a contains {1,7,2,9}, what's the value of a[a.length]?
Boo!!! Generates ArrayIndexOutOfBoundsException
4
3
9
4
What is the best signature for a method that returns higher of two values
(float, int)
(int, int)
(int, float)
(float, float)
5
What is the header for a function that when passed a float array, check if contains any zeroes.
boolean containsZero(int[] a)
float containsZero(float[] a)
boolean containsZero(float[] a)
void containsZero(float[] a)
6
If an array a contains {1,7,2,9}, what's the value of a[a.length - 3]?
1
9
7
2
7
If an array a contains {1,7,2,9}, what's the value of a.length?
1729
4
9
3
8
How many times is the loop with the following header executed? for(int i=5; i>=0; i=i/2)
6
indefinitely
5
0
9
How many times is the loop with the following header executed? for(int i=1; i >= 5; i++)
6
4
5
0
10
Which of the following gives the value of a number val with its last digit removed?
val-10
val%10
val+10
val/10
11
What is the value of the expression true && (false || (true || false))
true
1
false
0
12
Which of the following is the right way to instantiate (create) an array a to hold 25 integers?
a = new int[25];
int[] a = int[25];
int[] a = new int[25];
int[] a = new a[25];
13
What is the value of the expression (23%10*10 + 23/10)
3
2
32
23
14
What is the return type of a function that returns the higher of two values?
void
boolean
float
int
15
How can I check if an integer n is odd?
n%2 != 0
n%2 != 1
n%2 == 1
n%2 == 0
16
How many times is the loop with the following header executed? for(int i=5; i>=0; i--)
4
6
5
0
17
If a = {2, 4, 5}, what are it contents after for(int i=0; i < a.length - 1; i++) a[i]*=2;
{2, 4, 5}
{2, 4, 6}
{4, 8, 10}
{4, 8, 5}
18
How can I check if an integer n is even?
n/2 == 0
n/2 != 0
n%2 != 0
n%2 == 0
19
How many times is the loop with the following header executed? for(int i=1; i < 13; i=i+3)
5
6
3
4
20
Write a function that returns the outcomes of 100 rolls of a normal six-sided dice.
int outcomes()
int[] outcomes()
int[] outcomes(int[] values)
int outcomes(int[] values)