Level 1 - Intro to Java Flashcards
What is the escape sequence for creating a new line?
What is the escape sequence for creating a new line?
\n
What symbol terminates every line?
What symbol terminates every line?
;
Write two lines of code where the first prints “Hello”, the second prints “world”, and the net result is that they print together exactly as follows:
Helloworld
Write two lines of code where the first prints “Hello”, the second prints “world”, and the net result is that they print together exactly as follows:
Helloworld
System.out.print(“Hello”);
System.out.println(“world”);
In the following two lines of code, state which line is initializing and which is declaring.
int siv;
siv = 14;
int siv; //declaring
siv = 14; //initializing
What is output by the following code?
int x = 22;
int y = 6;
System.out.println(x % y);
4
What are the data types that we are able to input from the keyboard?
String, Int, double
Which of the following is illegal?
a. double d = 27;
b. int i = 203.932;
b. int i = 203.932; //int types can't hold decimals
What are the three different types of primitive variables that we have learned so far?
String, int, and double
Declare a string called myString that initializes to: Computer Science
String myString = "Computer Science"; //don't forget the quotes
What will the following code print out?
String s = “Mona Lisa”;
System.out.println(s.length( ));
String s = “Mona Lisa”;
System.out.println(s.length( ));
//Outputs 9 //remember to count the space between words
What is the escape sequence for a tab?
What is the escape sequence for a tab?
\t
What does this mean: 1.45667E24
What does this mean: 1.45667E24
1.45667 x 10^24
What would the following print out:
System.out.println( “my dog has fleas”.substring(4) );
What would the following print out:
System.out.println( “my dog has fleas”.substring(4) );
og has fleas
//start at character with index 4 until the end
What would the following print out:
System.out.println( “my dog has fleas”.substring(5, 9) );
g ha
//started at index 4 and end just before index 9
What is another way to write:
x = x + 1;
x++ or ++x