Search
Browse
Create
Log in
Sign up
Log in
Sign up
Upgrade to remove ads
Only $2.99/month
Intro to CP Final Exam Review 2020
STUDY
Flashcards
Learn
Write
Spell
Test
PLAY
Match
Gravity
Terms in this set (44)
Compiling is the process by which:
Program code is converted into a machine language version
If a program is not using whitespace properly, the program is not indented and spaced in a readable form, but....
will work properly regardless of the spacing.
An if statement is used in Java code to:
Execute certain statements based on the value of a variable
Give examples of compile-time (syntax), run-time, and logical errors
Compile-time: forgetting a semi-colon; typing a brace instead of a parenthesis
Run-time: dividing by zero
Logical: The output displays Hello Word instead of Hello World
How many distinct items or values can 1 bit hold, 2 bits, 3 bits...
1 bit = 2 items
2 bits = 4 items
3 bits = 8 items
n bits = 2^n items
What cycle do computers continuously follow?
Fetch-decode-execute
What characters are allowed in identifiers?
Numbers
Letters
$
_ (underscore)
Is RAM or ROM volatile? What does it mean to be volatile?
RAM. If the power is turned off or lost, you lose what is stored in the RAM.
What is another name for the brain of the computer?
CPU
Convert the following binary numbers to decimal numbers.
a) 111
b) 110010
c) 1000101
a) 7
b) 50
c) 69
Write a line of code to output the text "hi there", including the quotation marks.
System.out.println("\"hi there\"");
What is the output produced by the following segment of code?
int x = 10, y = 24;
if (x <= y && y < 50)
System.out.print("One");
if (x < y && x == y)
System.out.print("Two");
if (x > y || x >= 0)
System.out.print("Three");
OneThree
What is a bit?
A binary number, a single 0 or 1
What is the output produced by the following segment of code?
int x = 10, y = 24;
if (x == y)
System.out.print("One");
if (x < y)
System.out.print("Two");
else
System.out.print("Three");
Two
If x is an int where x = 1, what will x be after the following loop terminates?
while (x < 100)
x = x * 2;
128
What are the two ways you can insert a comment?
// Comment #1
/
Comment #2
/
What output would you get in the following two lines of code?
a) System.out.println ("The sum of 20 and 44 is " + (20+44));
b) System.out.println ("The sum of 20 and 44 is " + 20 + 44);
a) The sum of 20 and 44 is 64
b) The sum of 20 and 44 is 2044
Given the following declaration, what value is stored in fresult?
int num1=15, num2=6;
double fresult;
fresult=num1/num2;
2.0
The compiler generates an "unknown identifier" error from the following segment of code
Scanner scan = new Scanner(System.in);
System.out.println( "Hello!");
int radius;
Radius = scan.nextInt();
System.out.println("Radius: " + radius);
because:
the variable Radius in the fourth line is not declared.
What effect does \n and \t have when included in a string?
\n : Output is moved to the next line.
\t : Output is tabbed over.
Give an example of a variable that would be better defined as a double.
Give an example of a variable that would be better defined as an int.
int: the eggs sold by a dairy; the votes for a candidate
double: the height of a basketball player; how much you will pay for an item
Which of the following correctly evaluates the tens digit of a three digit number stored as int n? (Use 345 as your test number. The tens digit is 4.)
b is the correct answer
a) (n/100)%10
b) (n%100)/10
c) (n/100)/10
d) (n%10)%10
What is pseudocode? Can it be compiled?
Pseudocode is text based instructions that helps programmers develop algorithms.
It cannot be compiled because it is not Java text.
What is the equality operator? What is the assignment operator?
Equality operator: ==
Assignment operator: =
Write the main method line.
public static void main (String [] args)
What is an int data type and a double data type?
double variables can hold decimals
int variables only hold integer values (no decimals)
The output for the following code is:
final int LIMIT = 16;
int sum = 0, nextVal = 2;
while (sum < LIMIT)
{
sum = sum + nextVal;
nextVal = nextVal + 2;
System.out.println("nextVal is " + nextVal);
}
nextVal is 4
nextVal is 6
nextVal is 8
nextVal is 10
Give the output generated by the following statements:
int num=25, max=50, num2=100;
if ((max > num) && (num2==100))
System.out.println("lollipop");
else
System.out.println("Ringpop");
System.out.println("Soda Pop");
lollipop
Soda Pop
For the string name = "Cheryl L Vida" find the following.
a) What value is returned for name.length()?
b) What is stored as the new string for name.replace('L','x')?
a) 13
b) Cheryl x Vida
What does it mean to say Java is case-sensitive?
Writing a word in the Java text like String or string are different.
Creating an identifier Happy is different than HAPPY.
What is a byte?
One byte equals 8 bits.
Is the Internet and the World Wide Web the same?
No. The WWW is an application that runs on the Internet.
What type of programming language is Java?
Java is an object-oriented programming language.
Do comments and white-space affect how a program executes?
No.
How are the print and println methods different?
print will keep the next output on the same line
println will put the next output on the next line
What does the string concatenation operator, the plus sign (+)?
String concatenation operator, the plus sign (+), allows you to add one string to another.
Give an example of a character literal and a string literal.
Character literal : 'A'
String literal: "Hello"
Use the Math method to finish the code below.
Scanner scan = new Scanner (System.in);
System.out.println("Enter any number.");
number = scan.nextDouble();
// Assign num1 as the square root of number.
double num1 =
// Assign num2 as number raised to the power of 5.
double num2 =
Write a loop to display all the even integers between 2 and 36 inclusive.
public class Question
{
public static void main (String [] args)
{
for (int value = 2; value <= 36; value += 2)
System.out.println(value + " ");
}
}
Write a program using an if-else statement for a grade being passing or failing or the student needing extra help.Passing is 64 and above. Failing is 63 and below. If a student has a grade between 64 and 79, they are passing but should go for extra help.
import java.util.Scanner;
public class Question47{
public static void main (String [] args){
Scanner scan = new Scanner (System.in);
System.out.println ("Enter your grade: ");
int grade = scan.nextInt();
} }
Which block allows your sprite to make the sound of "meow"?
Play sound (meow)
Which block allows you to change the background of my project?
Switch backdrop to next backdrop
What is the notion of reset?
Changes your background back to the original background when the project starts again.
Changes your sprite back to the original position when the project starts again.
Changes your sprite back to the original costume when the project starts again.
Which block allows you to change the sprite size to half the original size?
Set size to 50%
YOU MIGHT ALSO LIKE...
Computer Science
106 terms
Chapter 2 Java
34 terms
CSCI-Final
138 terms
OTHER SETS BY THIS CREATOR
Medical Terminology (Ch.1: Basic Elements of a Med…
20 terms
Appendicular Skeleton (March 2020)
23 terms
English 4 (Vocab 9)
20 terms
Skeletal Terminology (February 2020)
5 terms