






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







What is the name of this file? public class Exercise01_02 { public static void main(String[] args) { //Display message Welcome to Java five times on the console System.out.println("Welcome to Java"); System.out.println("Welcome to Java"); System.out.println("Welcome to Java"); System.out.println("Welcome to Java"); System.out.println("Welcome to Java"); } } - answer Exercise01_ What is wrong with the naming of this file? public class exercise01_02 { public static void main(String[] args) { //Display message Welcome to Java five times on the console System.out.println("Welcome to Java"); System.out.println("Welcome to Java"); System.out.println("Welcome to Java"); System.out.println("Welcome to Java"); System.out.println("Welcome to Java"); } } - answer It is not capitalized.
Which word is not capitalized but should be? public class Exercise01_02 { public static void main(string[] args) { //Display message Welcome to Java five times on the console System.out.println("Welcome to Java"); System.out.println("Welcome to Java"); System.out.println("Welcome to Java"); System.out.println("Welcome to Java"); System.out.println("Welcome to Java"); } } - answer String Select the missing punctuation marks. public class Welcome __ public static void main __ String __ __ args __ __ System.out.println __ __ Welcome to Java __ __ __ __ __ - answer { ( [ ] ) { ( " " ) ; } } What words below are keywords? public class Welcome { public static void main(string[] args) { //Display message Welcome to Java on the console
Order the following program correctly so that it creates a Scanner object, prompts the user to enter a radius, computes area, and displays the result. public class ComputeArea { radius + " is " + area); double area = radius *(asterisk) radius *(asterisk) 3.14159; System.out.print("Enter a number for radius: "); import java.util.Scanner; public static void main(String[] args) { } } System.out.println("The area for the circle of radius " + Scanner input = new Scanner(System.in); double radius = input.nextDouble(); - answer import java.util.Scanner; public class ComputeArea { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter a number for radius: "); double radius = input.nextDouble(); double area = radius *(asterisk) radius *(asterisk) 3.14159; System.out.println("The area for the circle of radius " + radius + " is " + area); } } Identifiers can be which of the following: contain letters contain digits contain underscores (_)
contain dollar signs ($) can start with a letter can start with a digit can start with an underscore () can start with a dollar sign ($) can be a reserved word - answer contain letters contain digits contain underscores () contain dollar signs ($) can start with a letter can start with an underscore (_) can start with a dollar sign ($) The following is a sequence of lines in a program. After each line below, determine the value assigned to the variable: int r = 2; // r = __ double area = 5.0; // area = r = r + 1; // r = __ double circumference = 6.28 * r; //circumference = __ 5 = r; // r = __ - answer 2
3
error
discount = cost * discountRate; __ discount = cost * discountRate * 100; __ discount = (int) cost * discountRate * 100; __ discount = (int) (cost * discountRate * 100); __ discount = (int) (cost * discountRate * 100) / 100; __ discount = (int) (cost * discountRate * 100) / 100.0; __ discount = (int) (cost * discountRate * 10) / 10.0; __ - answer
25860 25868 258
Order the stages of the software development process. System Analysis Testing Requirement Specifications Maintenance System Design Deployment Implementation - answer Requirement Specifications System Analysis System Design Implementation Testing
public class EvenOdd { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter a number: "); int number = input.nextInt(); if (number % 2 == 0) System.out.println(number + " is even."); else System.out.println(number + " is odd."); } } What range of integers do the following lines of code produce? int guess1 = (int)(Math.random() *10); // from __ to __ int guess2 = (int)(Math.random() *10) + 1; // from __ to __ int guess3 = (int)(Math.random() *50); // from __ to __ int guess4 = (int)(Math.random() *11) + 50; // from __ to __ - answer 0, 9 1, 10 0, 49 50, 60 Put the code for swap in order: second = temp; int temp = first; first = second; - answer int temp = first; first = second; second = temp;
Truth Table for Operator! p --> !p false --> __ true --> __ - answer true false Truth Table for Operator && p1 p2 --> p1 && p true true --> __ true false --> __ false true --> __ false false --> __ - answer true false false false Truth Table for Operator || p1 p2 --> p1 || p true true --> __ true false --> __ false true --> __ false false --> __ - answer true true true false Truth Table for Operator ^ p1 p2 --> p1 ^ p