Flashcards
CIS 1030 - FlashCards

Cards in this deck (100)
- 1Which of the following statements opens a file named MyFile.txt and allows you to append data to its existing contents?FileWriter fwriter = new FileWriter("MyFile.txt", true); PrintWriter outFile = new PrintWriter(fwriter);
- 2When an object is created, the attributes associated with the object are calledinstance fields
- 3What will be the value of x after the following code is executed?210

- 4Which of the following strings could be passed to the DecimalFormat constructor to display 12.78 as 12.8%?0.00%
- 5Given the following statement, which statement will write the string "Calvin" to the file DiskFile.txt?diskOut.println("Calvin");

- 6What would be the value of discountRate after the following statements are executed?0

- 7The ________ is ideal in situations where the exact number of iterations is known.for loop
- 8What will be the result of executing the following code?An array of 6 values, ranging from 0 through 5 and referenced by the variable x, will be created.

- 9What will be displayed when the following code is executed?45,678.26

- 10What will be the value of bonus after the following code is executed?1000

- 11In an if-else statement, if the boolean expression is falsethe statement or block following the else is executed.
- 12Assume that inputFile references a Scanner object that was used to open a file. Which of the following while loops shows the correct way to read data from the file until the end of the file is reached?while (inputFile.hasNext())
- 13What would be the value of discountRate after the following statements are executed?0.04

- 14A ________ is a boolean variable that signals when some condition exists in the program.flag
- 15You should not define a class field that is dependent upon the values of other class fieldsin order to avoid having stale data.
- 16Variables are classified according to theirdata type
- 17A class that is defined inside of another class is called a(n)inner class
- 18Because Java byte code is the same on all computers, compiled Java programsare highly portable.
- 19Java requires that the boolean expression being tested by an if statement be enclosed ina set of parentheses.
- 20The scope of a local variable isthe method in which they are defined.
- 21What will be returned from the method, if the following is the method header?the address of an object of the Rectangle class

- 22How many bits are in a byte?8
- 23What will be the value of x after the following code is executed?100

- 24If you do not provide initialization values for a class's numeric fields, they willbe automatically initialized with 0.
- 25________ operators are used to determine whether a specific relationship exists between two values.Relational
- 26Using a counter-controlled while loop, write Java code to compute the sum of the integers from 1 to 100, inclusively, and output that result to the console. You will declare the integer variable num to count the number of executions (in the counter-controlled loop) and initialize it to 1. You will also declare the integer variable sum to store your computation result and initialize it to 0. Be sure to print your result to the console.

- 27How many times will the following for loop be executed?12

- 28This type of loop will always be executed at least once.posttest
- 29Before entering a loop to compute a running total, the program should firstset the accumulator variable to an initial value, usually zero.
- 30Class objects normally have ________ that perform useful operations on their data, but primitive variables do not.methods
- 31After the header, the body of the method appears inside a set ofbraces, {}.
- 32A for loop normally performs which of these steps?update the control variable during each iteration, test the control variable by comparing it to a maximum/minimum value and terminate when the variable reaches that value, initialize a control variable to a starting value (ALL OF THESE IS ANSWER)
- 33In UML diagrams, what symbol indicates that a member is public?+ (Plus sign)
- 34How many times will the following do-while loop be executed?5

- 35What would be the value of discountRate after the following statements are executed?0

- 36A method (unsure of answer)may have zero or more parameter variables.
- 37What is the result of the following expression?5

- 38What will be the result of the following code?The value variable will contain the lowest value in the numbers array.

- 39A loop that executes as long as a particular condition exists is called a(n) ________ loop.conditional
- 40UML diagrams do not containobject names
- 41To print "Hello, world" on the monitor, use the following Java statement:System.out.println("Hello, world");
- 42If str1 and str2 are both String objects, which of the following expressions will correctly determine whether or not they are equal?str1.equals(str2)
- 43What will be displayed after the following code has been executed?120

- 44The key word newcreates an object in memory.
- 45Which of the following expressions could be used to perform a case-insensitive comparison of two String objects named str1 and str2?str1.equalsIgnoreCase(str2)
- 46How many times will the following do-while loop be executed?1

- 47What will be the value of x after the following code is executed?40

- 48A UML diagram uses the ________ symbol to indicate that a member is private.-
- 49What will be the value of x after the following code is executed?15

- 50Which of the following is not a rule that must be followed when naming identifiers?Identifiers can contain spaces.
- 51Identifiers can contain spaces.a set of instructions that enable the computer to solve a problem or perform a task.
- 52In all but rare cases, loops must contain within themselvesa way to terminate.
- 53A method's signature consists ofthe method name and the parameter list.
- 54What does the following UML diagram entry mean?a public method with a parameter of data type double that does not return a value

- 55Using a for loop, write Java code that prints out all multiples of 5 from 0 to 100, inclusively, to the console.Need Answer - Q55
- 56A loop that repeats a specific number of times is known as a(n) ________ loop.count-controlled
- 57What will be displayed when the following code is executed?45,678.30

- 58What will be the values of ans, x, and y after the following statements are executed?ans = 60, x = 0, y = 50

- 59What would be the value of x after the following statements were executed?20

- 60When working with the PrintWriter class, which of the following import statements should you have near the top of your program?import java.io.*;
- 61The boolean expression in an if statement must evaluate totrue or false.
- 62This is a named storage location in the computer's memory.Variable
- 63Methods that operate on an object's fields are calledinstance methods
- 64The variable used to keep the running total is called a(n)accumulator
- 65If object1 and object2 are objects of the same class, to make object2 a copy of object1write a method for the class that will make a field by field copy of object1 data members into object2 data members.
- 66If you wish to use the System.out.printf method to print a string argument, use the ________ format specifier.%s
- 67A static field is created by placing the key word staticafter the access specifier and before the field's data type.
- 68Character literals are enclosed in ________, and string literals are enclosed in ________.single quotes, double quotes
- 69What will be the value of x after the following code is executed?15

- 70Which of the following expressions determines whether the char variable chrA is not equal to the letter 'A'?chrA != 'A'
- 71A block of code is enclosed in a set ofbraces
- 72A class's responsibilities includeboth the things a class is responsible for knowing and the things a class is responsible for doing
- 73What is syntax?Rules that must be followed when writing a program.
- 74Which of the following statements opens a file named MyFile.txt and allows you to read data from it?File file = new File("MyFile.txt"); Scanner inputFile = new Scanner(file);
- 75What is the value of ans after the following code has been executed?The code contains an error and will not compile. **Need == in if condition.**

- 76The ________ statement is used to create a decision structure, which allows a program to have more than one path of execution.if
- 77Rewrite the following if-else if statement as a switch statement:Need Answer #77
switch(letter)
{
case 'A':
S.o.p.("You selected A.");
break;
case 'B':
S.o.p.("You selected B.");
break;
case 'C':
S.o.p.("You selected C.");
break;
case 'D':
S.o.p.("You selected D.");
break;
default:
S.o.p.("Please enter A,B,C, or D.");
break;
}
- 78What will be displayed when the following code is executed?(NEED RIGHT ANSWER) Q78
30, 20, or 40
- 79What is the result of the following expression?7

- 80A search algorithmis used to locate a specific item in a larger collection of data.
- 81Overloading ishaving two or more methods with the same name, but different signatures.
- 82A constructorhas the same name as the class.
- 83Data hiding, which means that critical data stored inside the object is protected from code outside the object, is accomplished in Java byusing the private access specifier on the class fields.
- 84Which of the following expressions will determine whether x is less than or equal to y?x <= y
- 85When saving a Java source file, save it with an extension of.java.
- 86Another term for an object of a class is a(n)instance
- 87Which of the following statements determines whether temp is within the range of 0 through 100?if (temp >= 0 && temp <= 100)
- 88Using a switch statement, write Java code to output the season of the year to the console based on the value of an integer variable called month according to the following:Need Answer Q 88

- 89What will be the result of the following code?Q89 (NEED ANSWER)

- 90A constructor is a method thatperforms initialization or setup operations.
- 91A group of related classes is called a(n)package
- 92Assuming that inputFile references a Scanner object that was used to open a file, which of the following statements will read an int from the file?int number = inputFile.nextInt();
- 93What does the following code do?It allows the user to enter the name of the file that data will to be written to.

- 94The ________ loop is ideal in situations where you always want the loop to iterate at least once.do-while
- 95A ________ is a value that signals when the end of a list of values has been reached.sentinel
- 96________ is the term for the relationship created by object aggregation.Has a
- 97Which Scanner class method reads a String?nextLine
- 98Enclosing a group of statements inside a set of braces createsa block of statements.
- 99This statement tells the compiler where to find the JOptionPane class and makes it available to your program.import javax.swing.JOptionPane;
- 100Which of the following is not a valid Java comment?*/ Comment 2 /*
Information
- Description
- Computer Science Flashcards on CIS 1030 - FlashCards, created by Heather Williams on 28/06/2018.
- Created by
- Heather Williams
- Views
- 1
- Rating