Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

CS 151 - MODULE 2 | GUARANTEED SUCCESS STARTS HERE! LEARN, PRACTICE & EXCEL!

Rating
-
Sold
-
Pages
5
Grade
A+
Uploaded on
08-07-2026
Written in
2025/2026

CS 151 - MODULE 2 | GUARANTEED SUCCESS STARTS HERE! LEARN, PRACTICE & EXCEL!

Institution
CS 151
Course
CS 151

Content preview

CS 151 - MODULE 2 | GUARANTEED SUCCESS STARTS HERE!
LEARN, PRACTICE & EXCEL!


What is an algorithm? Answer: A finite, well-defined step-by-step procedure to solve a problem,
usually written before coding.
List the basic steps for writing an algorithm. Answer: Define the problem (inputs/outputs),
break into subproblems, identify steps for each subproblem, organize steps logically.
Give the algorithm steps to compute the area of a rectangle. Answer: 1) Declare variables, 2)
Get length, 3) Get width, 4) Compute area = length * width, 5) Print output.
What is the basic structure of a Java application class? Answer: public class ClassName { public
static void main(String[] args) { / code / } }
Explain the parts of 'public static void main(String[] args)'. Answer: public: access modifier;
static: belongs to class; void: returns nothing; main: entry method name; String[] args:
command-line args array.
How do you add algorithm steps into code as annotations? Answer: Use comments (// single-
line or / ... / block) to include algorithm steps and guide implementation.
What are the two floating-point types in Java and when to use each? Answer: float (32-bit
single precision) for memory saving in large arrays; double (64-bit double precision) as the
default for decimals and higher precision.
How do you declare multiple variables of the same type in one line? Answer: double length,
width, area;
How do you assign values to variables in Java? Answer: Use the assignment operator '='; e.g.,
length = 10;
How do you compute area from length and width in Java? Answer: area = length * width;
How do you print results to the console? Answer: System.out.println("The area for the
rectangle is " + area);
How do you read user input from the console using Scanner? Answer: Import java.util.Scanner;
create Scanner input = new Scanner(System.in); use input.nextDouble(), input.nextInt(), etc.
How do you import the Scanner class explicitly? Answer: import java.util.Scanner;
Why prefer explicit import over 'import java.util.*;'? Answer: Explicit import clarifies which
classes are used and avoids bringing in unnecessary classes.



APPHIA – Crafted with Care and Precision for Academic Excellence.
1

, What are identifiers in Java? Answer: Names for classes, methods, variables: sequences of
letters, digits, underscore (_), or dollar sign ($); cannot start with a digit; case-sensitive.
Is Java case-sensitive for identifiers? Answer: Yes: area, Area, and AREA are distinct identifiers.
What is a named constant and how do you declare one? Answer: A final variable that cannot
change. Example: final double PI = 3.14159;
What are Java naming conventions for variables, classes, and constants? Answer:
Variables/methods: camelCase. Classes: PascalCase. Constants:
ALL_CAPS_WITH_UNDERSCORES.
List Java's six primitive numeric types. Answer: byte, short, int, long, float, double.
What is the range and size of byte? Answer: 8-bit signed, range -128 to 127.
What is the range and size of short? Answer: 16-bit signed, range -32768 to 32767.
What is the range and size of int? Answer: 32-bit signed, range -2147483648 to 2147483647.
What is the range and size of long? Answer: 64-bit signed, very large range (approx -9.22e18 to
9.22e18).
What are the typical ranges for float and double? Answer: float: approx 1.4e-45 to 3.4e38 (32-
bit). double: approx 4.9e-324 to 1.8e308 (64-bit).
How do you read various primitive numeric types using Scanner? Answer: input.nextByte(),
.nextShort(), .nextInt(), .nextLong(), .nextFloat(), .nextDouble().
What arithmetic operators does Java provide? Answer: +, -, *, /, % (modulus)
What does the modulus operator (%) return? Answer: The remainder after integer division.
How to convert seconds into minutes and remaining seconds? Answer: minutes = seconds / 60;
remainingSeconds = seconds % 60;
How do you compute exponents in Java? Answer: Use Math.pow(base, exponent). Example:
Math.pow(2, 3) returns 8.0.
Name forms of numeric literals in Java. Answer: Decimal (100), octal (0144), hexadecimal
(0x64), binary (0b1100100), floating-point (3.14159).
State Java operator precedence for arithmetic. Answer: 1) Parentheses, 2)
Multiplication/Division/Modulus (left to right), 3) Addition/Subtraction (left to right).
What does augmented assignment mean? Give examples. Answer: Operators combining
arithmetic and assignment: i += 8 (i = i + 8), i = 8 (i = i 8), etc.




APPHIA – Crafted with Care and Precision for Academic Excellence.
2

Written for

Institution
CS 151
Course
CS 151

Document information

Uploaded on
July 8, 2026
Number of pages
5
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$14.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
Apphia
5.0
(1)

Get to know the seller

Seller avatar
Apphia California University Of Pennsylvania
View profile
Follow You need to be logged in order to follow users or courses
Sold
3
Member since
8 months
Number of followers
0
Documents
2682
Last sold
1 month ago
Apphia Tutors - Your Ultimate Study Companion for Academic Excellence.

Apphia Tutors is your all-in-one global study guide hub — built to make learning simple, smart, and rewarding. We bring together thousands of high-quality study materials, topic-specific notes, and verified answers designed to help students master every subject with ease. Whether you’re in high school, college, or university, Apphia Tutors has everything you need — from clear explanations to exam-ready practice questions. Our goal is to turn studying into a confident, stress-free journey toward success. Trusted by learners and educators worldwide, Apphia Tutors is where great grades begin and excellence grows.

Read more Read less
5.0

1 reviews

5
1
4
0
3
0
2
0
1
0

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions