CST 8116 Introduction To Computer Programming Midterm Exam 2022W PDF

Summary

This document is a computer programming midterm exam for 2022. The questions focus on concepts like data types, operators and creating programs using Java and Eclipse.

Full Transcript

## Quiz Submissions - 22W CST8116 Midterm Test ### Question 1 What is the term used to describe an error causing a program to take an action that the programmer did not intend? - compile-time error - syntax error - **run-time error** - typo ### Question 2 A \_\_\_\_\_\_\_\_\_\_\_ contains sequen...

## Quiz Submissions - 22W CST8116 Midterm Test ### Question 1 What is the term used to describe an error causing a program to take an action that the programmer did not intend? - compile-time error - syntax error - **run-time error** - typo ### Question 2 A \_\_\_\_\_\_\_\_\_\_\_ contains sequences of programming instructions that describe how to perform a particular task. - label - parameter - variabel - **method** ### Question 3 What is a logic error? - A violation of the rules of the computer language. - An error that is so severe that it generates an exception. - **A program that is syntactically correct but does not do what it is supposed to do.** - A missing main method. ### Question 4 Assume that the following Java statement is contained in the main method of the class named FunTime: ```java System.out.printLine("Java is Fun!"); ``` What is the name of the file generated by the Java compiler? - FunTime - FunTime.java - No file is generated due to an error. - **FunTime.class** ### Question 5 A(n) \_\_\_\_\_\_\_\_\_\_\_ is a software package that provides an editor, a compiler, and other programming tools. - **IDE** - GDE - GUI - CGI ### Question 6 In a flowchart, the \_\_\_\_\_\_\_\_\_\_\_ is used to represent processing. - lozenge - **parallelogram** - diamond - rectangle ### Question 7 Given the name of the public class is GroceryStore, and the filename for it on the hard disk is grocerystore.java, which of the following statements is correct? - the program will successfully compile, but will not run because the filename capitalization does not match the class name capitalization - the program will only compile if the public class name is changed to groceryStore and there are no syntax errors in it - **the program will successfully compile and run if there are no syntax errors in it** - the program will not compile because the filename capitalization does not match the class name capitalization ### Question 8 Java source code files end with file- extension \_\_\_\_\_\_\_\_\_\_\_ - class - **java** - txt - bytecode ### Question 9 Is an installation program required for Eclipse, or can it be extracted from a zip file? (this question only has two answer options) - **Eclipse can be extracted from a zip file, an installer is optional** - Eclipse must be installed using a specific installer program, you cannot get a zip file ### Question 10 What console command is used to display the version of Java run time environment (or virtual machine) installed? - version - **java -version** - javac -version - java cd\ ### Question 11 What is the output of the following code: ```java int num1 = 6; int num2 = 10; num1 = num2; num2 = num1; System.out.println(num1 + "," + num2); ``` - 10,6 - 6.10 - 6.6 - **10, 10** ### Question 12 Which line of code below correctly uses the assignment operator, given: int total; - 1+3 total; - total 1+ 3; - total 13; - **total = 1 + 3;** ### Question 13 Which of the following identifiers will compile in Java? - 1dog - **dog1** - class - dog#1 ### Question 14 Which one of the following lines of code correctly uses a method, given: int myNumber; - double myNumber = call (Math.PI); - double Math.pow(2,3) = myNumber; - myNumber = 0; - **System.out.println("My number is " + myNumber);** ### Question 15 If the values of 2.5 and "Hello" were sent in that specific order to a method, which one of the following methods would be used, noting that the method bodies have been purposely omitted? - void printValues(String value2, double value1) - **void printValues(double value1, String value2)** - void printValues(String value2, String value1) - void getValues(double value1, String value2) ### Question 16 In a certain program, an object of type Car is created in the main() method. What is assigned to the variable associated with this object? - **a reference to the object** - the attributes of the object - the number of objects of type Car that are in memory - the object ### Question 17 What Java package below provides classes that are used in all Java programs? - java.text - java.math - **java.lang** - java.util ### Question 18 Which of the following is not a way to create a breakpoint in Eclipse? - double-click on the bar to the left (blue bar) - right-click on the bar to the left (blue bar) and select toggle breakpoint - use the run menu and select toggle breakpoint - **use the file menu and select preferences** ### Question 19 When debugging in Eclipse to end the debugging session immediately we can use the \_\_\_\_\_\_\_\_\_\_\_ button. - Step Into - Step Over - **Terminate** - Step Return ### Question 20 Which debugging in Eclipse the command most commonly used to follow program execution line-by-line is \_\_\_\_\_\_\_\_\_\_\_ - Step Into - Step Return - **Terminate** - Resume ### Question 21 The access specifier in the declaration of instance variables should be \_\_\_\_\_\_\_\_\_\_\_. - protected - class - public - **private** ### Question 22 \_\_\_\_\_\_\_\_\_\_\_\_ methods are methods that exist to be used with an object created from a class. - Non-static - **Static** - Hidden - Controlled ### Question 23 What method of class Scanner reads in number data as data-type double? - nextInt() - **nextDouble()** - nextLine() - next() ### Question 24 Which of the following lines of Java code correctly import class Scanner from the Java API? - import java.lang.Scanner; - **import java.util.Scanner;** - import Scanner; - import Scanner.java: ### Question 25 What are two uses for keyword 'this' in the Java programming language? - **variable scope resolution, internal constructor calls** - access control, declaring constants - prefix for variable names, suffix for method names - to allocate memory, to clean up memory ### Question 26 Which of the following is a pseudocode statement that indicates use of the no-argument constructor for class Apple with variable apple1? - Apple apple1 - **Apple apple1 = new Apple();** - Apple():apple1 - Apple1 apple() ### Question 27 What sentence best describes a simple UML class diagram? - A rectangle with one column, and three rows. - A triangle with three rows. - A rectangle with three columns, and one row. - **A square with three columns, and three rows.** ### Question 28 What is the diagram type we are learning to use in UMLet? - **UML Class Diagram** - UML Sequence Diagram - UML Activity Diagram - UML Deployment Diagram ### Question 29 In a UML Class Diagram the fields are placed into the \_\_\_\_\_\_\_\_\_\_\_. - second row of the diagram - first row of the diagram - third row of the diagram - as a note alongside the diagram ### Question 30 What is the name of the template item for creating a simple UML class diagram in UMLet? - General Class - SimpleClass - CircumspectClass - **<<Stereotype>>** ### Question 31 What will be stored in variable number given the following statement? `int number = (int)(1.0/2.0);` - 1.0 - 2.0 - **0.5** - 0 ### Question 32 What is output from the following statement? `System.out.println("He said \"Good Day\"");` - "He said \"Good Day\"" - He said \"Good Day\" - **He said "Good Day"** - He said Good Day ### Question 33 To store data like shoe sizes (example 10 or 10.5), what data type is needed? - int - long - **double** - char ### Question 34 Which Java keyword is used to mark a method or variable as part of the class itself? - final - const - **static** - fixed ### Question 35 Which of the following Java operators is a unary operator? - **++** - * - / - % ### Question 36 The method name and parameter list together are called the method \_\_\_\_\_\_\_\_\_\_\_. - arguments - version - **signature** - return ### Question 37 Strings in Java cannot be changed once they are created in memory, this is referred to as being \_\_\_\_\_\_\_\_\_\_\_ - mutable - **immutable** - fixed - varied ### Question 38 Which of the following is a format specifier used with printf that represents a number with no decimal places? - %s - %f - **%d** - %n ### Question 39 Which of the following will format the output with 2 decimal places? - **System.out.printf("%.2f", 0.1234567);** - System.out.printf("%2.0f", 0.1234567); - System.out.printf("%f", 0.1234567); - System.out.printf("%0.12f", 0.1234567); ### Question 40 Which line of code below will work correctly when the program is run? - **String result = String.format("%s %d %.1f %n", "abc", 42, 10.5);** - String result = String.format("%d %s %.1f %n", "abc", 42, 10.5); - String result = String.format("%.1f %d %s %n", "abc", 42, 10.5); - String result = String.format("%s %.1f %d %n", "abc", 42, 10.5); ### Question 41 What kind of operator is the <= operator? - Ternary - Inequality - **Relational** - Arithmetic ### Question 42 A(n) \_\_\_\_\_\_\_\_\_\_\_ decision is a decision in which two conditions must be true for an action to take place. - OR - XOR - **AND** - OR-ELSE ### Question 43 What prints out from the following java code snippet, given num1 = 4; and num2 = 6; ```java System.out.println(num1 != num2); ``` - 6 - **true** - 4 - false ### Question 44 What prints out from the java code snippet, given x = 18; and y = 13; ```java System.out.println(x+++--y); ``` - 28 - 31 - **29** - 30 ### Question 45 In java, we define a constant called EPSILON and use it to compare integer data types. - **True** - False ### Question 46 Which of the following statements is true, given String s1 = "today"; and String s2 = "today"; - one String will be created in the String Pool on the Heap. - s1 and s2 will different references to "today" - **two separate Strings will be created in the String Pool on the Heap.** - s1 and s2 will each have their own copy of "today" ### Question 47 Which of the following statements is true, given String s1 = "Today"; and String s2 = "today"; - System.out.println(s1 == s2); // reports true - **System.out.println(s1.equals(s2)); // reports true** - System.out.println(s1.equals(s2)); // prints "Today" - System.out.println(s1.equals(s2)); // reports false ### Question 48 What command line command below is used to configure the Git global email address after installing Git - **git config --global user.name "User Name"** - git config --global user.email "[email protected]" - git --config user.name "User Name" - git --global user.email "email@document is available free of charge on ### Question 49 In the context of programming what does the acronym VCS represent? - **Version Control System** - Verbose Central Support - Some sort of storage media - Varied Containment Security ### Question 50 What command line command is used to commit changes to a file in a Git repository? - **git commit** - git init - git add - git log

Use Quizgecko on...
Browser
Browser