Video Lessons 1-6: Output in Java, Escape Characters, User Input and Variables, Data Types, Number Calculations, Numeric Casts

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Given an int variable x=3, System.out.println(x/2); will print...

1 (Java truncates when doing int division)

Given int x=11; double y=x/2; what does System.out.println(y); print?

5.0

What character is needed at the end of each statement in Java?

;

Valid comments in Java are a) // b) /* */ c)*/ /* d) #

A, B

Which of the following are valid variable names in Java? a) 1name b) first name c) name1 d) name f) print

C, D

Given an int var x, which of the following is not a Java unary operation? a) x++; b) x-=1; c) x/=3; d) x=x*x;

D

Which Java statement prints out the following? a) System.out.println("J\tA\t\tV\t\t\tA"); b) System.out.println("J\nA\n\nV\n\n\nA"); c) System.out.println("J\t\nA\t\t\nV\t\t\t\nA"); d) System.out.println("J\n\tA\n\t\tV\n\t\t\tA");

D

What type of data type should you use to store average rainfall?

Double

T or F: In Java, the forward slash, "/" is used to tell the compiler to just print the next character.

False

T or F: The horizontal tab in Java is represented as "\T"

False (It is \t)

T or F: char a = "A"; is a valid statement in Java

False (Use single quotes)

T or F: This is the correct syntax for printing both the string "Hi there" plus the value stored in the variable "n" System.out.println("Hi there + n");

False; System.out.println("Hi there " + n);

T or F: To declare a constant, use all capital letters

T

T or F: For convention, start variables with lowercase, start classes with uppercase

True

T or F: The scanner class in Java has multiple methods to read input of various types, including String, int, and double.

True

T or F: Running a Java program is a two step process.

True (It is compile, run)

T or F: When the Java compiler finds an error it tries to tell you both the type of error and the line number the error occurred on.

True (Java will sometimes get lost with what you are trying to do, and print out a lot of confusing possible errors. You will have to look for patterns and learn techniques to debug your code.)

What does the following print

Welcome to CSA!


Set pelajaran terkait

Leadership Exam 3 Practice Questions & Lippincott Questions

View Set

Managing Compensation- Chapter 9

View Set

HESI Case Study Coronary Artery Disease (CAD)

View Set

Health and Nutrition Chapter 13 - Nutrition for Life

View Set