Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

CPS 180 Exam 1 Questions and Answers 2023: Java Programming Fundamentals, Exams of Health sciences

A comprehensive set of questions and answers for cps 180 exam 1, covering fundamental concepts in java programming. It delves into key topics such as data types, variables, operators, control flow, and string manipulation. Particularly useful for students preparing for their first java programming exam, offering insights into common exam questions and their solutions.

Typology: Exams

2024/2025

Available from 02/20/2025

Tutor001
Tutor001 🇺🇸

2.8

(6)

1.1K documents

1 / 8

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
CPS 180 Exam 1 Questions and Answers 2023|
Latest Update (Graded A+).
Keywords - answers>Lower case words reserved by java (can't be identifiers)
ex: public, static, class, void
Expressions - answers>a part of a statement (like a clause)
Statements (source code) - answers>a complete java instruction that causes the
computer to perform an action
The name of the .java source code - answers>must match the name of the class
Bytecode - answers>what java compiles to so the virtual machine interprets and
runs
WORM language - answers>java can write once and run many
Programming process - answers>1. Define what the program does
2. Visualize the program running on the computer (try to create it in your mind)
3. Use design tools to create a model of the program (use pseudocode)
4. Check the model for logical errors
[Date]
pf3
pf4
pf5
pf8

Partial preview of the text

Download CPS 180 Exam 1 Questions and Answers 2023: Java Programming Fundamentals and more Exams Health sciences in PDF only on Docsity!

CPS 180 Exam 1 Questions and Answers 2023|

Latest Update (Graded A+).

Keywords - answers>Lower case words reserved by java (can't be identifiers) ex: public, static, class, void Expressions - answers>a part of a statement (like a clause) Statements (source code) - answers>a complete java instruction that causes the computer to perform an action The name of the .java source code - answers>must match the name of the class Bytecode - answers>what java compiles to so the virtual machine interprets and runs WORM language - answers>java can write once and run many Programming process - answers>1. Define what the program does

  1. Visualize the program running on the computer (try to create it in your mind)
  2. Use design tools to create a model of the program (use pseudocode)
  3. Check the model for logical errors
  1. Enter the code and compile it
  2. Correct any errors found and repeat 5/
  3. Run program with test data for input
  4. Correct runtime errors and repeat 5-
  5. Validate the results of the program (see if it solves original problem) Logical errors - answers>mistakes that cause the program to produce erroneous results Runtime errors - answers>Errors that occur while your program runs RAM - answers>Random Access Memory, divided into bytes, you can pick any two random locations and it will take the same time to access the data Algorithm - answers>instructions given to solve the problem Variables - answers>created by programmer who assigns it a programmer- defined identifier (ex: hours) a named storage location in the computer's memory

print functions - answers>print : prints message println : advances cursor to next line after message printf : allows for changing format of printed message Java escape sequences - answers>\n : newline \t : tab \b : backspace \r : carriage return (takes cursor to beginning of current line) \ : backslash (prints backslash) ' : single quote (prints single quote) " : double quote (prints) String Concatenation - answers>Combining several strings into a single string, or combining a string with other data into a new, longer string. Literal - answers>a value that is written into the code of a program Legal: 123, 4, 's', "hello" Not legal: 'dfsjd' byte - answers>1 byte, range -128 to +

short - answers>2 bytes, range -32,768 to +32, int - answers>4 bytes, range -2,147,483,648 to +2,147,483, long - answers>8 bytes, range -9,223,372,036,854,775,808 to +9,223,372,036,854,775, float - answers>4 bytes, range ±3.410 x 10^-38 to ±3.410 x 10^38, with 7 digits of accuracy double - answers>8 bytes, range ±1.710 x 10^-308 to ±1.710 x 10^308, with 15 digits of accuracy boolean - answers>True or False char - answers>single character Unicode - answers>character data, set of 65536 characters Arithmetic Operators - answers>+ : addition

  • : subtraction
    • : multiplication / : division % : modulus += : adds number given to original (x+=5 ... x=x+5)

String Methods - answers>A string is a class, so objects that are instances of it have methods meant to manipulate string objects Length method - answers>a string method that runs the length method on the object pointed to by the value variable ex: stringSize = value.length( ); Comments - answers>// : single line comment /.../ : block comment /*.../ : allows comments to be documented by the javadoc Scanner - answers>reads input from the keyboard

  • import java.util.Scanner;
  • Scanner keyboard = new Scanner(System.in); if statement - answers>decides whether or not a code is executed, uses a boolean Relational Operators - answers>> : greater than < : less than

= : greater than or equal to <= : less than or equal to == : equal to != : not equal to

Comparing Characters - answers>Characters are ordinal (they have order) so they can be compared ex: char c = 'A'; if (c < 'Z') System.out,println("A is less than Z"); if-else statements - answers>adds the ability to conditionally execute the code when the if condition is false Nested if statements - answers>if statement inside another if statement that is only executed if the outer is true if-else-if statements - answers>use if then else if then else can make nested logic simpler to write