Flashcards
Introduction to Computer Science 201 Midterm Flashcards
Cards in this deck (5)
- 1Which keyword do we need to specify in order to access another class from another package?Import
- 2Explain the difference between a String variable and a String literal.String literals are hard coded text enclosed with double quotation marks, e.g: “Hello World”. A
String variable is a variable that holds a string literal. E.g: String name = “Anson”;
System.out.println(name) is different than System.out.println(“name”) - 3Explain why you must declare every variable in Java before you can reference itBe
cause the Java compiler won’t know what the undeclared variable is. It needs to check what
it’s data type is. - 4Explain what truncation is and when it occurs.Truncation is where the floating points of a numeric type are cut off from the number, and
only the integer part remains. For example, 5/9 = 0.555
555... but because 5 and 9 are both
integers, the .55555... is truncated and the result leaves you with 0 - 5What is the result of 5/0? How about 5.0/0?5/0 will result in a run-time error somewhere in the program. 5.0/0 will result in infinity
Information
- Description
- Flashcards on Introduction to Computer Science 201 Midterm Flashcards, created by Carlos Guzman Valencia on 14/10/2018.
- Created by
- Carlos Guzman Valencia
- Views
- 2
- Rating