Download CPS 180 Exam 1 Questions and Answers 2023/2024Solutions Latest updated and more Exams Information Technology in PDF only on Docsity! 1 [Date] CPS 180 Exam 1 Questions and Answers 2023/2024Sol utions Latest updated 1) Why do computers use zeros and ones? - 2 [Date] answers>because digital devices have two stable states and it is natural to use one state for 0 and the other for 1 2) Monitors, printers, status lights are all examples of - answers>output devices 3) Mice, trackpads, keyboards, scanners, 5 [Date] 8) Computer can execute the code in ____________. - answers>machine language 9) a technical definition of the language that includes the syntax and semantics of the Java programming language. - answers>Java language specification 10) contains predefined classes and interfaces for 6 [Date] developing Java programs. - answers>Java API 11) A Java program block starts with a - answers>open brace ({) and ends with a closing brace (}). 12) Executes Java Programs also know as Java Runtime Environment. A machine that runs and interprets Java 7 [Date] Bytecode. - answers>Java Virtual Machine (JVM) 13) True or False. A Java application must have a main method. - answers>True 14) True or False.The keywords in Java are all lowercase - answers>True 10 [Date] 20) The JDK command to compile a class in the file Test.java is - answers>javac Test.java 21) The ________ loads Java bytecode to the memory - answers>class loader 22) ________ translates high- level language program into 11 [Date] machine language program. - answers>Compiler 23) The source code should be stored in a file named - answers>.java 24) _______ is an operating system. - answers>Windows XP 12 [Date] 25) True or False. Java is an object-oriented programming language. - answers>True 26) The main method header is written as ________. - answers>public static void main(String[] args) 27) True or False. Java was originally developed by a team led by James Gosling at 15 [Date] 32) True or False. Java source code can be executed on a Java Virtual Machine. - answers>False 33) Which JDK command is correct to run a Java application in ByteCode.class? - answers>java Bytecode 34) To declare a constant PI, you write ________. - 16 [Date] answers>final double PI = 3.14159; 35) What is the exact output of the following code? 36) double area = 3.5; 37) System.out.print("area"); 38) System.out.print(area); - answers>area3.5 17 [Date] 39) -25 % 5 is ________. - answers>0 40) ________ is the code with natural language mixed with Java code. - answers>Pseudocode 41) True or False. The result of an integer division is the integer part of the division; the fraction part is truncated. - answers>True 20 [Date] answers>x - 2 <= 4 && x - 2 >= -4 47) True or False. A break statement is required for a switch-case statement in Java. - answers>False 48) True or False. In a switch statement, the default case must appear last among all cases. Otherwise, it would 21 [Date] result in a compilation error. - answers>False 49) The ________ operator can be used to compare two values. - answers>relational 50) What is the value of the following expression? 51) true || true && false - answers>True 22 [Date] 52) True or False. "smiles".substring(1, 5) returns "mile". - answers>True 53) Unicode for "0" to "9" - answers>48 to 57 or /u0030 to /u0039 25 [Date] 59) The statement System.out.printf( %3.1f , ʺ ʺ 1234.56) outputs ________. - answers>1234.6 60) Analyze the following code: Code 1: 61) boolean even; 62) if (number % 2 == 0) even = true; 63) else 64) even = false; 65) Code 2: 26 [Date] 66) boolean even = (number % 2 == 0); - answers>Both Code 1 and Code 2 are correct, but Code 2 is better. 67) What is "Welcome" + 1 + 1 * 2? - answers>Welcome12 68) To obtain the sine of 35 degrees, use ________. - answers>Math.sin(Math.toR adians(35)) 27 [Date] 69) You compare two strings s1 and s2 using ________. - answers>s1.compareTo(s2) 70) The ________ method parses a string s to an int value. - answers>Integer.parseInt(s); 71) Math.sqrt(4) returns ________. - answers>2.0 30 [Date] 79) Which of the following statements are the same? 80) x -= x + 4 81) x = x + 4 - x 82) x = x - (x + 4) - answers> 83) What is x after the following statements? 84) int x = 1; 85) x *= x + 1; - answers>x is 2 31 [Date] 86) True or False. You can define a variable twice in a block. - answers>False. 87) True or False. You can always assign a value of long type to a variable of int type without loss of precision. - answers>False 32 [Date] 88) True or False. You can define a constant twice in a block. - answers>False 89) True or False. Any assignment statement can be used as an assignment expression. - answers>True 90) True or False. You can always assign a value of long type to a variable of int type 35 [Date] 97) What is the printout of the following code: 98) double x = 10.1; 99) int y = (int)x; 100) System.out.println("x is " + x + " and y is " + y); - answers>x is 10 and y is 10 101) Which of the following operators has the highest 36 [Date] precedence? - answers>Casting