Computer Programming Final

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Strings are abled to be manipulated using String methods, but they cannot be lengthened or shortened. What term is used to describe this?

immutable

Which of the following code segments imports the Scanner class to program

import java.util.Scanner;

In the sentence below, what index position is the first letter "n"?I'm in the here and now.

index position 5

In a while loop, the code that repeats over and over again until the condition is met is located where?

inside the loop body

Which of the following would correctly find the length of a string?

length

Which debugging error generates output that the programmer was not expecting?

logical error

Which of the debugging errors allows a program to run all the way through and produce output without shutting down?

logical error

Which of the following is not one of the 4 data types that will be the focus of the course this semester?

long

What part of the program is where "action" occurs?

method

Do semicolons go after conditionals or loop headers?

no

What is the output of the code segment shown? int num1 =25; System.out.println("num1");

num1

Variable names cannot contain...

numbers, spaces, or special characters

Which step of the Scanner class is the following code segment?Scanner scan = new Scanner(System.in);

Step 2

What does the following code segment print? int x = -5; while (x < 0) { x++; System.out.print(x + "); }

-4 -3 -2 -1 0

Which string method is the correct one to change a value to all capital letters (Pay attention to syntax)

.toUpperCase( )

Consider the following code segment, which line of code has an error? 1. boolean sunny = true; 2. int num1 = 25.5; 3. System.out.println("num1"); 4. System.out.println("Today is sunny: 11 + sunny);

2

How many lines of output does the following code segment produce? System.out.print("Maroon and "); System.out.println("gold are the school's"); System.out.print("colors. ");

2

Which line of code represents an initialized variable declaration? System.out.println("You're taking a quiz"); double cost = 25.99; double fees; System.out.println(cost*2);

2

Which line of code represents an uninitialized variable declaration? System.out.println("You're taking a quiz"); double cost = 25.99; double fees; System.out.println(cost*2);

3

How many times will the following loop run? int i = 3; while (i < 7) { System.out.println(""); i++; }

4

Using the substring method and the sentence below, what index positions would you use to have the following output: "is Women"?March is Women's History Month.

6,14

Which operator would you use in a conditional to see if two integers are equal to each other?

==

What is Java?

An object-oriented language ( Your Answer )

What is the first step of the loop process?

Declare and initialize the loop variable

Identify the value of the variable declaration in the code segments below: System.out.println("Gold Day"); String day = "Gold";

Gold

What is the output of the following code segment? String varName = "McNamara"; if (varName.equalsIgnoreCase("mcnammara")) { System.out.println("Maroon"); } else if (varName.equalsIgnoreCase ("MCNAMARA")) System.out.println("Gold"); } else { System.out.println("You're taking a quiz!"); }

Gold

What is the output of the following code segment? String varName = "Forestville"; if (varName.equals("forestville")) { System.out.println("Good morning"); } else { System.out.println("Good night"); }

Good night

In Java, what are methods?

How the program interacts with objects and where the "action" of the program takes place.

Step one of the scanner class

Import scanner class from java utilities library

What if anything is wrong with the following code segment? System.out.println("Hello world!);

It is a syntax error because it is missing a closing quotation mark.

Who is the creator of the Java programming language?

James Gosling

Which code segment creates a Scanner object named input?

Scanner input = new Scanner(System.in);

Of the 4 Scanner class steps, which ones are not repeated more than once?

Steps 1 and 2

In the space provided, create an initialized variable declaration that has a value of Today is Friday.

String date = "Today is Friday.";

In the space provided, create a variable declaration that has not been initialized - it should be able to take user input that answers the question of what month they were born.

String month; month = scan.nextLine();

Which of the following is the correct way to create an initialized variable declaration that uses the string data type? (value is Mr. Walther)

String name = "Mr. Walther";

In the space provided, write a print statement that has the following statement concatenated with the variable firstName at the end. "Hello my name is ".

System.out.println("Hello my name is "+firstName+".");

In the space below, write a print statement that is the code version of the following sentence: Today is varDay and it is the year varYear varDay and varYear are variables that MUST be concatenated into the rest of the string literal.

System.out.println("Today is "+varDay+" and it is the year "+varYear);

In the space below, write a print statement that will find the length of the following string: String varMess = "Today is Friday";

System.out.println(varMess.length());

When using the replace method, which character should go first inside the parenthesis?

The character being replaced

What is the result of the following code segment? int x = 3; while (x > 0) { System.out.println(x); }

The loop will run indefinitely

Which of the following is true for a runtime error?

The program runs until the point where it reaches invalid data and then stops.

What is the third step needed when creating a loop?

Update/change the variable's value

What is the output of the following code segment? boolean isCold = false; if (isCold) { System.out.println("Wear gloves"); } else { System.out.println("Wear a coat"); }

Wear a coat

What is the output of the following code segment? boolean study = true; boolean passQuiz = true; boolean passquiz = false; boolean Study = false; if (study || passQuiz) { System.out.println("You passed!"); } else { System.out.println("Better Luck Next Time!"); }

You passed!

What does this code segment represent? System.out.println(5 * 25);|

an expression

Which of the following describes the 4th step of the Scanner class?

assigns user input to variable declaration

Classes are known as what in Java?

blueprints

What are classes known as when referenced in Java?

blueprints

Objects are known as what in Java?

building blocks

Which of the following properly describes what step 2 of the Scanner class does?

creates and declares a scanner object

In the space below, write a variable declaration with the name cost that has a value of 3.25

double cost = 3.25;

Based on the question below, which of the following is the correct 4th step of the Scanner class? How much is a gallon of gas? Answer: 3.69

double gasPrice = scan.nextDouble( );

In the space provided, create an initialized variable declaration that has a value of 2.25.

double price = 2.25;

Identify the value of the following code segment: boolean rain = false;

false

Using camel casing, which of the following is the correct way to make "gold day" a variable?

goldDay

Which of the following will allow you to compare multiple conditions within the same code segment?

if...else if...else statement

Which string method allows you to change characters that were in the original string?

replace

Which of the debugging errors best explains the following scenario: The program asks the user to enter the year they were born so it can calculate their age in 10 years. The user types their name in instead, resulting in an error.

runtime

Which of the following will properly find the character at the 4th index position of the following string: String sample = "Today is Friday";

sample.charAt(4);

Using the sentence below, what character is at index position 7?This is computer programming

space

The following would result in what kind of error? INT num1; System.out.println("What is your favorite number?");

syntax

True or false: Java is case and character sensitive

true

Write a replacement for the missing loop header so that the loop prints out: 0 2 4 6 8 10 int count 0; = /* missing Loop header */ { System.out.print(count + "); count += 2; }

while (count <=10)

increase the value of x by 10 each time the loop runs

x+=10;

reduce the value of y by 2 each time the loop runs

y-=2;

Is && a compound boolean operator?

yes

Or operator

||


संबंधित स्टडी सेट्स

Ch 20 Central Nervous System Stimulants

View Set

Medical Terminology: Chapter 2 (Body Structure)

View Set

6ème - Lesson 1 - Classroom English

View Set

Forearm and Hand - Study Guide (Priscilla)

View Set

MGMT 321 Chapters 1-4 Written answers good

View Set

Ch. 13 Learning curve, Biology of Organisms Ch.13 Leaning Curve, Bio 1010 Chapters 14-17, Bio Chapter 15, Biology of Organisms Ch.14 Leaning Curve, Biology Ch. 14, Biology launchpad chapter 15 questions USM

View Set