COP 2258 - Lesson Quizzes

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

(L8) There is only one way to decompose a program into classes.

False

How many times can a student attempt a zyBook assignment prior to the due date?

unlimited times

(L5) Which of the following loops prints "Welcome to Java" 10 times? A: for (int count = 1; count <= 10; count++){ System.out.printIn("Welcome to Java"); } B: for (int count = 0; count < 10; count++) { System.out.printIn("Welcome to Java"); } C: for (int count = 1; count < 10; count++) { System.out.printIn("Welcome to Java"); } D: for (int count = 0; count <= 10; count++) { System.out.printIn("Welcome to Java"); }

AB

(L2) The code below outputs Jane Williams on different lines and then starts a new output line. Code Example: System.out.println("Jane"); System.out.print("Williams"); Output: Jane Williams

False

(L3) The following statements correctly calculate the numDays: int numDays; int numYears; numDays = numYears * 365;

False

(L4) Assume the following: String userName = "Jessica"; The following code will return 'a': userName.charAt(userName.length() )

False

(L4) In Java, || has a higher precedence than &&.

False

(L4) The following code segment correctly tests for equality: String month = "October"; if(month == "October") { System.out.printIn("The month is October.") }

False

(L5) A break statement in a loop causes an immediate jump to the loop condition check

False

(L5) The following for loop executes 21 times. (Assume all variables are properly declared.) for (i = 1; i <= 20; i = i + 1) System.out.printIn(i);

False

(L6) If a program contains the declaration int[][]salePrice = new int [100][100]; then the statement System.out.print(salePrice[3]); outputs all the values in row 3 of the array

False

(L8) A class' private helper method can be called from main(), which is defined in another class.

False

(L8) A public member method may not call another public member method.

False

(L3) Which method in the Scanner class reads until it reaches a whitespace character? In other words, this method allows you to read one word at a time. a. nextDouble() b. nextInt() c. nextString() d. nextLine() e. next()

Its not c. nextString() [I GOT IT INCORRECT]

zyBooks is REQUIRED for this course. Most assignments (participation activities, challenges, and labs) will be accessed via zyBooks. A zyBooks subscription must be purchased no later than the beginning of the SECOND WEEK of the semester. I am aware that I will not be successful if I do not purchase zyBooks for this course.

True

(L6) Given the declaration int[][] score = new int[5][8]; Which of the following outputs the array components in row order? a. for (i = 0; i < 5; i++) for(j = 0; j < 8; j++) System.print(score[i][j]); b. No answer text provided. c. for (i = 0; i < 8; i++) for (j = 0; j < 5; j++) System.print(score[i][j]); d. for (i = 0; i < 8; i++) for (j = 0; j < 5; j++) System.out.print(score[j][i]);

a. for (i = 0; i < 5; i++) for(j = 0; j < 8; j++) System.print(score[i][j]);

(L3) Choose the best type for each of the following variables to represent each item: 1. The amount of money in the back. 2. The number of hairs on a person's head. 3. The average score earned on an exam. a. 1) double 2) int 3) double b. 1) double 2) int 3) int c. 1) double 2) double 3) double d. 1) int 2) int 3) int e. 1) int 2) int 3) double

a. 1) double 2) int 3) double

(L4) Suppose that the input is 5. Consider the following code. Scanner console = new Scanner(System.in); int alpha = 7; int beta = console.nextInt(); switch (beta) { case 5: alpha = alpha + 1; case 6: alpha = alpha + 2; case 7: alpha = alpha + 3; default: alpha = alpha + 5; } System.out.print(alpha); What is the output of the following code? a. 18 b. 10 c. 17 d. 14 e. 15

a. 18

(L5) What is the output of the following Java code? int num = 14; while (num <= 32) num = num + 10; System.out.printIn( num ); a. 34 b. 36 c. 32 d. 30

a. 34

(L6) What is the output of the following program fragment? int[] alpha = {100, 200, 300, 400, 500}; int i; for (i = 4; i >= 0; i--) System.out.print(alpha[i] + " "); a. 500 400 300 200 100 b. 400 300 200 100 0 c. 500 400 300 200 d. 4 3 2 1 0 e. It cannot be answered from the information given

a. 500 400 300 200 100

(L3) If numMarbles is initially 89, what is numMarbles after the following code executes? numMarbles = numMarbles + 4 a. 93 b. 94 c. 4 d. 90 e. 89

a. 93

(L6) What is the output of the following program fragment? int[] gamma = {5, 10, 15}; for(int count = 0; count < 3; count++) System.out.print(":"+gamma[count]); a. :5:10:15 b. :5:10 c. :0:1:2 d. :0:1 e. It cannot be answered from the information given.

a. :5:10:15

(L5) What is the output of the following Java code? int count = 6; System.out.print("Sem") do{ System.out.print('i'); count--; } while (count >= 5); System.out.printIn("nole"); a. Semiinole b. Semnole c. Seminole d. Semiiinole

a. Semiinole

(L2) What type of error means that the programmer violated a programming language's rules on how symbols can be combined to create a program? a. Syntax error b. Logic error c. Buffer error d. Command line error

a. Syntax error

(L7) The method ____ is the first line of a method. a. declaration b. statement c. argument d. address

a. declaration

(L3) What will the following resulting type be, given the following expression? Assume numSales1, numSales2, and totalSales are int variables. (double)(numSales1 + numSales2) / 2 a. double b. char c. int d. String

a. double

(L7) A(n) ____ variable is known only within the boundaries of the method. a. local b. method c. instance d. double

a. local

(L6) After execution of the code fragment int[] arr = new int[5]; int i; for (i = 0; i < 5; i++) { arr[i] = i + 2; if (i >= 3) arr[i-1] = arr[i] + 3; } what is contained in arr[1]? a. 2 b. 3 c. 7 d. 8 e. None of these.

b. 3

(L2) When a new programmer complains: "The program compiled perfectly but isn't working.", what type of errors are these typically? a. Syntax errors b. Logic errors c. Run-time errors d. Compile-time errors

b. Logic errors

(L2) A _____ is a text parser that can get numbers, words, or phrases from an input source such as a keyboard. a. Print b. Scanner c. Method d. System.out

b. Scanner

(L2) Which of the following statements will allow you to print the name Mary Smith to the screen? a. Input("Mary Smith") b. System.out.print("Mary Smith"); c. Scanner name.next("Mary Smith"); d. System.in("Mary Smith");

b. System.out.print("Mary Smith");

(L8) A constructor that can be called without any arguments is called this a. member b. default c. normalized d. class

b. default

(L7) A(n) ____ is a program module that contains a series of statements that carry out a task. a. argument b. method c. declaration d. application

b. method

(L7) A(n) ____ causes a value to be sent from a called method back to the calling method. a. inheritance relationship b. return statement c. method statement d. instantiation

b. return statement

(L4) Assume x=4 and y=5, which of the following is true? a. !(x==4)^ y != 5 b. x != 4 ^ y == 5 c. x != 5 ^ y != 4 d. x == 5 ^ y == 4

b. x != 4 ^ y == 5

(L4) Given the following code, convert the if-else statement to a single assignment statement using a conditional expression. if (x > 30) { y = 20; } else { y = x; } a. y = (x > 30) ? 20; b. y = (x > 30) ? 20 : x; c. y = 20 ? (x > 30) : x; d. y = x ? 20 : (x > 30);

b. y = (x > 30) ? 20 : x;

(L2) Which of the following is are incorrect ways to include multi-line comments in your code? a. * /Declare all variables/* b. * /Declare all variables*/ c. /*Declare all variables*/ d. /*Declare all variables/*

d. /*Declare all variables/* [PARTIAL CREDIT]

(L3) What is the Java source filename extension? What is the Java bytecode filename extension? a. 1) .java 2) .js b. 1) .class 2) .java c. 1) .class 2) .jv d. 1) .java 2) .class

d. 1) .java 2) .class

(L2) When was the first public release of Java? a. 1994 b. 1991 c. 1998 d. 1995 e. 2000

d. 1995

(L5) What is the output of the following Java code? int count; int num = 2; for (count = 1; count < 4; count++){ num = num + 3; System.out.print(num + " "); } System.out.printIn(); a. 5 8 b. 2 5 8 c. 5 d. 5 8 11

d. 5 8 11

(L4) int x, y; if (x < 4) y = 2; else if (x > 4) { if (x > 7) y = 4; else y = 6; } else y=8; Based on the code above, what is the value of y if x = 4? a. 6 b. 4 c. 2 d. 8

d. 8

(L3) What is the result of the following statement? Math.pow(3.0, 3.0) a. 9 b. 27 c. 20 d. 6

b. 27

Which of the following represents the learning activities that each student is responsible for in zyBooks, which is the required textbook for this course?

All of these. (zyLabs, Participation Activities, Challenge Activities)

Which of the following statement represents the "Late Submission Policy" for this course?

Assignments submitted after the due date are not graded and a zero will be issued.

According to the TIOBE index, which programming languages are considered the top THREE most popular languages.

C, Java, and Python

(L2) It is good practice to deliberately and consistently use whitespace to make a program more readable. Programmers usually follow conventions defined by their company, team, instructor, etc., such as: •Use blank lines to separate conceptually distinct statements. •Indent lines the same amount. •Align items to reduce visual clutter. •Use a single space before and after any operator like =, +, *, or << to make statements more readable.

True

(L3) A character is stored in memory as a number. For example, 'N' is stored as 78 in memory.

True

(L6) In Java, a two-dimensional array is actually an array of references to one-dimensional arrays.

True

(L6) The statement int[][] scaleFactor = { {5, 2, 8, -2} {6, 0, 1, 7} }; is a valid statement for declaring an initializing the scaleFactor array.

True

(L6) The values in an array are accessed by an index, whereas the values in a class are accessed by name.

True

(L7) A method body provides information about how other methods can interact with it

True

(L7) An application's main() method must have a void return type.

True

(L8) A car presents an abstraction to a user, including a steering wheel, gas pedal, and brake.

True

(L8) An accessor method accesses fields but may not modify a class' fields.

True

ALL STUDENTS must complete a WEEKLY ATTENDANCE CHECK-IN. It is located on the "Modules" page on the course website in the "Record Attendance" section. Attendance represents 5% of the total grade in the course. A check-in serves as a "nudge" to stay focus and to stay on top of the weekly assignments.

True

Coding is the process of breaking down problems.

True

Issues with ANY grades, except exams, must be dealt with 7 calendar days of the posting of the grade. After 7 days the grade is final and cannot be challenged.

True

(L7) What is the result of the following program? public class FindMax { public static void main (String [ ] args) { int max = 0; max (1, 2, max); System.out.println(max); }//end of main method public static void max (int value1, int value2, int max) { if(value1 > value2) max = value1; else max = value2; }//end of max method }//end of class a. 2 b. 0 c. 1 d. 3

b. 0

(L7) public int mystery(int x, int y) { if (x >= y) return x - y; else return x + y; } Based on the code above, what would be the output of the following statement? System.out.println(mystery(8,7)); a. 15 b. 1 c. 7 d. 8

b. 1

(L5) What is the result of the following code segment? for (int i = 1; i <= 12; i++) { System.out.print(i + " "); i++; } a. 1 2 3 4 5 b. 1 3 5 7 9 11 c. 1 2 3 4 5 6 7 8 9 d. 2 4 6 8 10

b. 1 3 5 7 9 11

(L3) How do you denote a comment line? How do you denote a comment paragraph? a. 1) /* 2) /*/ b. 1) // 2) /* */ c. 1) // 2) /* /* d. 1) *// 2) //

b. 1) // 2) /* */

(L5) How many times will the following code print "Florida State University"? int count = 0; while (count < 10) { System.out.printIn("Welcome to Java"); count++; }//end of while loop a. 9 b. 10 c. 11 d. 8

b. 10

(L5) Which is an infinite loop? a. loopCount = 1; while (loopCount , 3) ; { System.out.printIn("Hello") ; loopCount = loopCount + 1; } b. loopCount = 5; while(loopCount > 3); { System.out.printIn("Hello"); loopCount = loopCount - 1; } c. loopCount = 1; while (loopCount < 3); { System.out.printIn("Hello"); } d. loopCount = 4; while(loopCount < 3) ; { System.out.printIn("Hello") ; loopCount = loopCount + 1; }

c. loopCount = 1; while (loopCount < 3); { System.out.printIn("Hello"); }

(L5) What is the output of the following Java code? int num = 15; while (num > 0) num = num - 3 ; System.out.printIn(num) ; a. 12 b. 3 c. 0 d. 15

c. 0

(L6) What are the contents of arr after the for loop? int j = 0; for (i = 0; i < 5; i++) { arr[i] = i + j; j = j + 1; } a. 0, 1, 2, 3, 4 b. 1, 2, 3, 4, 5 c. 0, 2, 4, 6, 8 d. 1, 3, 5, 7, 9

c. 0, 2, 4, 6, 8

(L4) After the execution of the following code, what will be the value of num if the input value is 4? Scanner console = new Scanner(System.in); int num = console.nextInt(); if (num > 5) num = num + 10; else if (num >= 3) num = num + 17; System.out.printIn( num ); a. 4 b. 14 c. 21 d. 31

c. 21

(L4) Assume the following code: String team = "Florida State Seminoles"; System.out.printIn( team.length() + "" + team.substring(1,6)); What is the result of the above code? a. 23 lor b. 23 lorida c. 23 lorid d. 24 lori e. 24 lorida

c. 23 lorid

(L7) public int mystery(int x, int y) { if (x >= y) return x - y; else return x + y; } Based on the code above, what would be the output of the following statement? System.out.println(mystery(8, mystery(2, 1)); a. 5 b. 11 c. 7 d. 13

c. 7

(L4) Suppose the following strings are declared as follows: String city1 = "Miami"; String city2 = "Orlando"; What is the results of the following expressions? city1.concat(city2).lastIndexOf('a'); a. 10 b. 7 c. 8 d. 9 e. 5

c. 8

(L2) What will the following code output? Code: int feet = 5; int inches = 3; System.out.print("Mary you are "+feet+"feet "+inches+"inches tall."); a. "Mary you are "+5+"feet"+3+" inches tall." b. Mary you are feet feet inches inches tall. c. Mary you are 5 feet 3 inches tall. d. "Mary you are "+feet+"feet "+inches+"inches tall." e. Mary you are feet inches tall.

c. Mary you are 5 feet 3 inches tall.

(L5) Which of the following is true about a while loop? a. The body of the loop is executed at least once b. The logical expression controlling the loop is evaluated before the loop is entered and after the loop exists. c. The body of the loop may not execute at all. d. It is a post-test loop

c. The body of the loop may not execute at all

(L7) Data items you use in a call to a method are called ____. a. method declarations b. instance variables c. arguments d. headers

c. arguments

(L3) Which of the following statements best declares and initializes a double variable? a. double depositFunds = $55.69; b. double depositFunds = $56; c. double depositFunds = 55.69;

c. double depositFunds = 55.69;

(L3) Which of the following statements is a valid declaration of use of a constant double variable named INTEREST_RATE? a. INTEREST_RATE=2.97; b. FINAL DOUBLE INTEREST_RATE = 2.97; c. final double INTEREST_RATE = 2.97; d. double INTEREST_RATE = 2.97;

c. final double INTEREST_RATE = 2.97;

(L7) The ____ method executes first in an application, regardless of where you physically place it within its class. a. run() b. start() c. main() d. execute()

c. main()

(L8) Which operator explicitly allocates an object of the specified class type? a. (.) dot b. constructor c. new d. deconstructor

c. new

(L7) public static double secret(int first, double second) { double temp; if (second > first) temp = first * second; else temp = first - second; return temp; } Which of the following is a valid call statement to the method given above? a. public static int secret(5, 4.8); b. secret(int x, double y); c. secret(5, 4.8); d. secret(int 5, double 4.8);

c. secret(5, 4.8);

(L4) What is the output of the following Java code? int x = 0; if (x > 0) System.out.printIn("positive "); System.out.print("zero "); System.out.printIN("negative"); a. zero b. positive zero negative c. zero negative d. negative

c. zero negative

(L2) Which of the following is considered good practice for fixing errors reported by the compiler? a. Focus on the next to the last error message, fix it, and ignore the rest of the errors initially. b. Focus on the last error message and, fix it and ignore the rest of the errors initially. c. None of these. d. Focus on the first error message, fix it and ignore the rest of the errors initially.

d. Focus on first error message, fix it and ignore the rest of the errors initially.

(L8) What statement is required to enable a user to utilize the String class? a. import java.lang.String; b. import java.String; c. import java.util; d. Nothing; Strings are already imported

d. Nothing; Strings are already imported

(L4) Suppose that s1, s2, and s3 are three strings, given as follows: String s1 ="To Be, or not to be,"; String s2 ="That is the question:"; String s3 ="Whether 'tis nobler in the mind to suffer"; What is the results of the following expression? s2.concat(s1) a. To Be, or not to be, That is the question: b. That is the question: Whether 'tis nobler in the mind to suffer c. Whether 'tis nobler in the mind to sufferTo be, or not to be, d. That is the question:To Be, or not to be,

d. That is the question:To Be, or not to be,

(L3) Which of the following is a valid variable name? a. 5String b. int c. 89#Height d. depositFunds

d. depositFunds

(L7) When a variable ceases to exist at the end of a method, programmers say the variable ____. a. is lost b. is undeclared c. is out of memory range d. goes out of scope

d. goes out of scope

(L5) What is the missing statement below in the for loop that would make the loop iterate 5 times. for (i = 2; __________ i++){ ....... } a. i < 5; b. i < 6; c. i <4; d. i < 7;

d. i < 7;

(L7) public static double secret(int first, double second) { double temp; if (second > first) temp = first * second; else temp = first - second; return temp; } What is the name of the above method? a. double b. second c. first d. secret

d. secret

(L4) Assume x = 4 and y = 5, which of the following is true? a. x > 5 && y > 5 b. x > 5 || y > 5 c. x < 5 && y < 5 d. x < 5 || y < 5

d. x < 5 || y < 5

(L4) int x = 46; int y = 3; switch (x % 9) { case 0: case 1: y++; case 2: y = y -2; break; case 3: y = y + 2; case 4: break; case 5: case 6: y = y + 3; } System.out.printIn(y); a. 3 b. 6 c. 5 d. 46 e. 2

e. 2


Ensembles d'études connexes

🍡💜🍡Endocrine System🍡💜🍡

View Set

pharmacology online practice 2017 B

View Set

AIT 524 - Week 8 (Table Creation and Management)

View Set

Art History: Romanesque Europe - Chapter 12

View Set