Quiz07-Review - Vernon Computer Science

advertisement
PreAP Computer Science
Review Quiz 07
Take out a piece of paper and PEN.
The quiz starts one minute after
the tardy bell rings.
You will have 30 – 60 seconds
per question.
Title the quiz as shown below
The quiz starts in ONE minute.
Name
Period
Date
Review Quiz 07
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
EC.
Question 01
Which of these is/are heading(s) of a void method?
I.
II.
III.
IV.
V.
public static void hello()
public static void hello(int x, int y)
public static int hello()
public static double hello(double z)
public static String hello()
(a) I only
(b) I and II only
(c) III only
(d) III, IV and V only
(e) III and V only
Question 02
Which of these is/are heading(s) of a return method?
I.
II.
III.
IV.
V.
public static void hello()
public static void hello(int x, int y)
public static int hello()
public static double hello(double z)
public static String hello()
(a) I only
(b) I and II only
(c) III only
(d) III, IV and V only
(e) III and V only
Question 03
Consider the heading of the qwerty method below:
public static void qwerty(int w, int x, int y, int z)
Which of the following properly calls qwerty?
(a) qwerty(‘w’,‘x’,‘y’,‘z’);
(b) qwerty(1,2,3,4);
(c) qwerty(true,false);
(d) qwerty(“John”,3.16,‘#’,1);
(e) qwerty(1,‘#’,3.16,“John”);
(f) qwerty(1,3.16,“John”,‘#’);
Question 04
Consider the heading of the qwerty method below:
public static void qwerty(char w, char x, char y, char z)
Which of the following properly calls qwerty?
(a) qwerty(‘w’,‘x’,‘y’,‘z’);
(b) qwerty(1,2,3,4);
(c) qwerty(true,false);
(d) qwerty(“John”,3.16,‘#’,1);
(e) qwerty(1,‘#’,3.16,“John”);
(f) qwerty(1,3.16,“John”,‘#’);
Question 05
Consider the heading of the qwerty method below:
public static void qwerty(int w, char x, double y, String z)
Which of the following properly calls qwerty?
(a) qwerty(‘w’,‘x’,‘y’,‘z’);
(b) qwerty(1,2,3,4);
(c) qwerty(true,false);
(d) qwerty(“John”,3.16,‘#’,1);
(e) qwerty(1,‘#’,3.16,“John”);
(f) qwerty(1,3.16,“John”,‘#’);
Question 06
Consider the heading of the qwerty method below:
public static void qwerty(boolean hello, boolean goodbye)
Which of the following properly calls qwerty?
(a) qwerty(‘w’,‘x’,‘y’,‘z’);
(b) qwerty(1,2,3,4);
(c) qwerty(true,false);
(d) qwerty(“John”,3.16,‘#’,1);
(e) qwerty(1,‘#’,3.16,“John”);
(f) qwerty(1,3.16,“John”,‘#’);
Question 07
Consider the heading of the qwerty method below:
public static void qwerty()
Assume that both the qwerty method and the main method are in the Hello
class. Which of the following properly calls qwerty from the main method?
(a) qwerty();
(e) Both a & b
(b) Hello.qwerty();
(f) Both c & d
(c) System.out.println(qwerty());
(d) System.out.println(Hello.qwerty());
Question 08
Consider the heading of the qwerty method below:
public static int qwerty()
Assume that both the qwerty method and the main method are in the Hello
class. Which of the following properly calls qwerty from the main method?
(a) qwerty();
(e) Both a & b
(b) Hello.qwerty();
(f) Both c & d
(c) System.out.println(qwerty());
(d) System.out.println(Hello.qwerty());
Question 09
Consider the heading of the qwerty method below:
public static void qwerty()
Assume method qwerty is in the Hello class & method main is in another
class. Which of the following properly calls qwerty from the main method?
(a) qwerty();
(e) Both a & b
(b) Hello.qwerty();
(f) Both c & d
(c) System.out.println(qwerty());
(d) System.out.println(Hello.qwerty());
Question 10
Consider the heading of the qwerty method below:
public static int qwerty()
Assume method qwerty is in the Hello class & method main is in another
class. Which of the following properly calls qwerty from the main method?
(a) qwerty();
(e) Both a & b
(b) Hello.qwerty();
(f) Both c & d
(c) System.out.println(qwerty());
(d) System.out.println(Hello.qwerty());
Question 11
Which of these methods will receive an int and
return the next int?
(a)
public static int qwerty (int n)
{
return n + 1;
}
(c)
public static int qwerty (int n)
{
return n – 1;
}
(b)
public static char qwerty (char n)
{
n++; return n;
}
(d)
public static char qwerty (char n)
{
n--; return n;
}
Question 12
Which of these methods will receive an int and
return the previous int?
(a)
public static int qwerty (int n)
{
return n + 1;
}
(c)
public static int qwerty (int n)
{
return n – 1;
}
(b)
public static char qwerty (char n)
{
n++; return n;
}
(d)
public static char qwerty (char n)
{
n--; return n;
}
Question 13
Which of these methods will receive a char and
return the next char?
(a)
public static int qwerty (int n)
{
return n + 1;
}
(c)
public static int qwerty (int n)
{
return n – 1;
}
(b)
public static char qwerty (char n)
{
n++; return n;
}
(d)
public static char qwerty (char n)
{
n--; return n;
}
Question 14
Which of these methods will receive a char and
return the previous char?
(a)
public static int qwerty (int n)
{
return n + 1;
}
(c)
public static int qwerty (int n)
{
return n – 1;
}
(b)
public static char qwerty (char n)
{
n++; return n;
}
(d)
public static char qwerty (char n)
{
n--; return n;
}
Question 15
Given the method below, what will be the output of
System.out.println(qwerty(10,5)); ?
public static int qwerty (int p, int q)
{
return p + q;
}
(a) 50
(d) 2
(b) 15
(e) 1
(c) 5
(f) 0
Question 16
Given the method below, what will be the output of
System.out.println(qwerty(10,5)); ?
public static int qwerty (int p, int q)
{
return p - q;
}
(a) 50
(d) 2
(b) 15
(e) 1
(c) 5
(f) 0
Question 17
Given the method below, what will be the output of
System.out.println(qwerty(10,5)); ?
public static int qwerty (int p, int q)
{
return p * q;
}
(a) 50
(d) 2
(b) 15
(e) 1
(c) 5
(f) 0
Question 18
Given the method below, what will be the output of
System.out.println(qwerty(10,5)); ?
public static int qwerty (int p, int q)
{
return p / q;
}
(a) 50
(d) 2
(b) 15
(e) 1
(c) 5
(f) 0
Question 19
Given the method below, what will be the output of
System.out.println(qwerty(10,5)); ?
public static int qwerty (int p, int q)
{
return p % q;
}
(a) 50
(d) 2
(b) 15
(e) 1
(c) 5
(f) 0
Question 20
Given the method below, what will be the output of
System.out.println(qwerty(10,5)); ?
public static int qwerty (int p, int q)
{
return 1;
}
(a) 50
(d) 2
(b) 15
(e) 1
(c) 5
(f) 0
Extra Credit
Which of the following conditions will cause the
qwerty method to have a Runtime Error?
public static int qwerty
(int a, int b, int c, int d)
{
return (a + b) / (c – d);
}
(a) All 4 numbers are positive.
(b) One of the numbers is 0.
(c) a and b are equal.
(d) c and d are equal.
(e) c and d are not equal.
Download