click below
click below
Normal Size Small Size show me how
jav chapt2b
| Question | Answer |
|---|---|
| 31)each statement ends with______ | A semicolon(;) |
| 32)when System.out.printIn completes its task,it positions the output cursor on_____ | To the beginning of the next line in the command window |
| 33)when System.out.print completes its task,it positions the output cursor on_____ | At the next character without a space |
| 34)the backslash is identified by_____ | \ |
| 35)the backslash(\) is called a/an________,it indicates that_______ | An escape character and it indicates that a special character is to be output |
| 36)\n is an escape sequence,true or false | true |
| 37)the escape sequence \n represents the ______,which positions the cursor on______ | New line character, the next line |
| 38)examples of escape sequences are | \n, \t, \r, \\, \” |
| 39)print the following according th java convention; the man shouted "please help me" | System.out.print(“\”please help me\””) |
| 40)What is method,printf() used for? | For displaying formatted data |
| 41)when a method requires multiple arguments,the arguments are separatd by with____ and this is known as a _______ | Commas, comma-separated lists |
| 42)method printf's first argument is a _______that may consist of _______and ________ | Format string which may consist of fixed text and format specifier |
| 43)the format specifiers begin with sign____and are followed by a_____ | %sign and followed by a character that represents the data type |
| 44)the format specifier______is a placeholder for a string | %s |
| 45)the format specifier____is a placeholder for an int value | %d |
| 45)what does the below print; System.out.printf("*\n**\n***\n") | *(newline)**(new line)***(new line) * ** *** |
| 46)what does the following code print? System.out.printIn("welcome\nto\njava\nprogramming!) | welcome to java programming! |
| 47)in the example below; System.out.printf("%s=%d\n","answer",(x+z)); the first %s(format specifier) is a placeholder for_____ | answer |
| 48)what does System.out.printf("%s\n%s\n","Welcome to","java programming") | Welcome to(new line)java programming(new line) Welcome to Java programming |
| 49)Integers are________,give examples | whole numbers eg 0.-33,55 |
| 50)why is an import declaration important? | it helps the compiler locate a class that is used in a program |
| 51)where in a java file should the import declaration appear? | before the class declaration |
| 52)how do you declare variables | by using variable types followed immediately by variable name |
| 53)variable declaration statments do not end with a semicolon. true or false | false |
| 54)define a variable | a variable is a location in the computer's memory where a value can be stored for use later in a program |
| 55)write an import declaration that helps the compiler locate a class that is used to read data for use in a program | import.java.util.Scanner |
| 56)write the expression that creates a scanner object | Scanner input=new Scanner(System.in) |
| 57)a scanner enabled a program to_______ | to read data for use |
| 58)_______is the standard input object | System.in |
| 59)scanner method_____obtains an integer for use in a program | nextIn() |
| 60)write the full expression that reads an integer from a user | input.nextIn() |