




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
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
1 / 8
This page cannot be seen from the preview
Don't miss anything!
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
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
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
= : 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