Log in to StudySoup
Get Full Access to USF - COP 251 - Study Guide - Final
Join StudySoup for FREE
Get Full Access to USF - COP 251 - Study Guide - Final

Already have an account? Login here
Reset your password

USF / OTHER / COP 251 / What are the types of parameters?

What are the types of parameters?

What are the types of parameters?


School: University of South Florida
Department: OTHER
Course: Programming Concepts
Professor: Schinnel small
Term: Spring 2017
Tags: final study guide, toString, and Constructors
Cost: 50
Name: COP 2510 Final Exam Review
Description: These notes go over what's going to be on the final exam. This exam is comprehensive, but this has the main rundown.
Uploaded: 04/25/2017
10 Pages 32 Views 7 Unlocks


What are the types of parameters?

Exam Rundown:

- Multiple Choice ~ 60%

- Free Form Questions ~ 40%

- Sign the pledge

- Know your Section

Comprehensive Exam

● More emphasis on post Midterm concepts

○ Loops and Switches (CH 5-6)

○ Arrays (CH 8)

○ Classes and Methods (Ch 4, 7)

○ Some File Reading/Writing

Earlier concepts may be embedded in more advance questions.


1. The statement

if (x < 0)

 y = x;


 y = 0;

can be rewritten using a conditional operator is A) y = (x < 0) ? x : 0;

What is a static method?

B) x = (x < 0) ? y : 0;

C) (x < 0) ? x ; y;

D) y = (x < 0);

E) y = if (x < 0) x : 0;

2. What is the value of x after the following code is executed? Int x = 10;



x *= 20;


while (x > 5);

A) 10

B) 20

C) 200

D) 2000

E) x’s value will change because it is an infinite loop.

3. How many times will the innermost statement execute? for (int m = 0; m < 100; m++)

for (int n = 0; n < 100; n++)

x ++;

A) 0 times

B) 100 times

C) 200 times

D) 1,000 times

What are the loops and switches in mathematics?

E) 10,000 times

4. Assuming that variable A is an array of ints. Consider the following code segment: int x = 0;

for (int k = 1; k < A.length; k++)

if (A{k] < A[x]) Don't forget about the age old question of matthew garberina

x = k;

Which of the following describe what x is after executing the code segment? A) x is the smallest element of A.

B) x is the largest element of A.

C) x is the index of the smallest element of A.

D) x is the index of the largest element of A.

E) It is not possible to determine what x is.

5. If int [] arr = new int {15];

And the statement

arr[15] = 0;

is executed, then which of the following Exceptions is thrown?If you want to learn more check out bnad 276 university of arizona

A) NullPointerException

B) ArrayIndexOutofBoundsException

C) ArithmeticException

D) IOException

E) No exception will be thrown.

6. (Assume values is an int array that is completely filled, and that the loop control variable has been declared.) Which of the following loops would adequately add 1 to each element stored in values?

A) for (j=1; j < values.length; j++) values[j]++;

B) for (j=0; j < values.length; j++) values[j]++;

C) for (j=0; j<= values.length; j++) values[j]++;

D) for (j=0; j<values.length-1; j++) values[j]++;

E) for (j=1; j<values.length-1; j++) values[j]++; We also discuss several other topics like livescort charlotte
We also discuss several other topics like csueb number

7. Which of the following methods is a static method? The class in which the method is defined is given in parentheses following the method name.

A) equals (String)

B) toUpperCase (String)

C) sqrt (Math)

D) format (DecimalFormat)

E) paint (Applet)

8. In order to preserve encapsulation of an object, we do all of the following except for which one?

A) Make the instance data private

B) Define class methods to access and manipulate the instance data C) Make class methods public

D) Make the class final

E) All of the above preserve encapsulation

9. Having multiple class methods of the same name where each method has a different number of or type of parameters is known as

A) encapsulation

B) information hiding

C) tokenizing

D) importing

E) method overloading

For 10 through 15

Use the following class defini)on for the next questions:

 public class Student


 private String name;

 private String major;

 private int hours;

 public Student(String newName, String newMajor, If you want to learn more check out uncg password reset

 int newHours)


 name = newName;

 major = newMajor;

 hours = newHours;



10. Which of the following could be used to instantiate a new Student s1? A) Student s1 = new Student ("Jane Doe", "Computer Science", "33"); B) s1 = new Student();

C) Student s1 = new Student ("Jane Doe", "Computer Science", 33); D) new Student s1 = ("Jane Doe", "Computer Science", 33);

E) new Student(s1);

11. Assume that another method has been defined that will compute and return the student’s class rank (Freshman, Sophomore, etc). It is defined as: “public String getClassRank ()”

Given that s1 is a student, which of the following would properly be used to get s1’s class rank? Don't forget about the age old question of dr kalumba

A) s1 = getClassRank();

B) s1.toString();

C) s1.getHours();

D) s1.getClassRank();

E) getClassRank();

12. If “inputFile” references a Scanner object that was used to open a file, which of the following statements will read and “int” from the file?

A) int number = inputFile.nextInt();

B) int number = inputFile.next();

C) int number = inputFile.readInt();

D) int number = inputFile.integer();

E) int number = inputFIle.gotoInt();

13. Create a Random object and generate two numbers between 0.0 (inclusive) and 5.0 (exclusive). (If variables are not provided, declare them.)


Random randnum = new Random();

float num1 = randnum.nextFloat() * 5;

float num2 = randnum.nextFloat() * 5;

14. You are to write portions for a class called Employee.

Given that an employee has a name, a position and wages, define the instance data for this class:

private String name, position;

private double wages;

15. Write the constructor, which is passed the employee’s name and position. Answer:

public Employee (String empname, String empposition)


name = empname;

position = empposition;

wages = 0.0;


Note: All other data instances are initialized as well.

16. Rewrite the following constructor using the THIS reference.

“public Student (String newName, String newMajor,

int newHours)


name = newName;

major = newMajor;

hours = newHours;



public Student (String name, String major,

int hours)


this.name = name;

this.major = major;

this.hours = hours;


17. Write a toString method that outputs the name, major and hours for the Student class. Answer:

public String toString ()


return name + “\t” + major + “\t”

+ hours;


18. Write a method (which receives one parameter, “side”) to compute the volume of a cube.


double volume (double side)


return side*side*side;


Page Expired
It looks like your free minutes have expired! Lucky for you we have all the content you need, just sign up here