Garantie de satisfaction à 100% Disponible immédiatement après paiement Lire en ligne ou en PDF Tu n'es attaché à rien 4,6 TrustPilot
logo-home
Examen

CP213 MIDTERM EXAM QUICK TIPS Object-Oriented Programming Wilfrid Laurier University

Note
-
Vendu
-
Pages
16
Qualité
A+
Publié le
15-10-2025
Écrit en
2025/2026

CP213 MIDTERM EXAM QUICK TIPS Object-Oriented Programming Wilfrid Laurier University

Établissement
WLU CP213
Cours
WLU CP213

Aperçu du contenu

CP213 MIDTERM EXAM QUICK TIPS Object-Oriented Programming 2025-2026 Wilfrid Laurier University

Class (blueprint) → Objects (multiple cars or one car) → Varriables (colour, brand) → methods (start, accelerate)

Quick Tips:

string.charAt() is a method in Java that returns the
character at a specific position (index) in a string

for (int i = 0; i < s.length(); i++): This
loop runs from the first character (index 0) to the last
character of the string.

Character.isLetter(currentChar) is part of
Java's Character class, and it checks whether the given
character (currentChar in this case) is a letter.

string.length(), meaning it will check every character including spaces “,” and “.” etc. in the string.
Returns the length of the string.

Character.isUpperCase() to check if a character is an uppercase letter.

string.toLowerCase() / string.toUpperCase(): Converts the string to lowercase or
uppercase.

\n is an escape sequence used to insert a newline character, which moves the output cursor to the
next line.

\" allows you to include a double quote inside a string literal. Example:
System.out.println("This is \"fun\"!");
Prints This is "fun"!

array.length: Returns the length of the array.
int[] arr = {1, 2, 3, 4};
int len = arr.length; // len will be 4




Common format specifiers:
printf function
System.out.printf(format_string, arguments);

● %d: For printing integers. Adds leading zeros
○ int number = 19;

, ○ System.out.printf("%05d%n", number);
● 00019
● %f: For printing floating-point/decimal numbers.
○ "%6.2f" → This indicates that the output will take 6 characters no more and have
2 decimal places. And in this case it will add spaces and count those as
characters at the beginning of the code.
○ %.2f: Limits to 2 decimal places.
● %s: For printing strings.
○ double number = 19.987;
○ String word = "hi";
○ System.out.printf("%8.2f %s", number, word);
● 19.99 hi
● %c: For printing characters.
● %n: For printing a new line (same as \n but platform-independent)
● %g format specifier in Java is used with the printf method to format floating-point
numbers (like float and double) in a more compact form.


- java.text.NumberFormat is a class in Java used to format and parse numbers, including currency,
percentages, and general numbers.

Common methods:

● getInstance(): Returns a general number formatter for the default locale.
● getCurrencyInstance(): Returns
a currency formatter for the default
locale.
● getPercentInstance(): Returns
a percentage formatter for the default
locale.
● format(): Formats the number into
a string.
● parse(): Parses a string to retrieve
the numerical value.




- Libraries in Java are called packages

DecimalFormat Class
- that allows you to format decimal numbers (like float or double) into strings in a
customizable way.
- Always apply the following to the class; import java.text.DecimalFormat;

, Common Patterns:

● 0: Displays a digit or zero if no digit is present.
● #: Displays a digit but doesn't add zero if no digit is present.
● .: Decimal point.
● ,: Grouping separator (e.g., thousands separator).

Example Patterns:

● "###,###.##": Formats the number with commas and up to 2 decimal places.
● "000.00": Ensures exactly 3 digits before the decimal and 2 after.
○ DecimalFormat moneyFormat = new DecimalFormat("$###,###.##");
System.out.println("Formatted price: " + moneyFormat.format(price));
○ Outcome: Formatted price: $1,234.50

DecimalFormat(“0.00%”) → Prints to 2 decimal places so if the given number is 0.907
the outcome will be 90.70%



Curly Braces {}
Purpose: Curly braces are used to define blocks of code.

Parentheses ()
Purpose: Parentheses are used to pass arguments, group expressions, or control flow statements.

String str = null; // str does not reference any String object
Example: String temp=null; (temp string does not contain anything, empty)

Asking a user for input
- import java.util.Scanner; allows the
program to read user input.
- Scanner scanner = new
Scanner(System.in); creates a scanner to read
from the console. In Java, one of the common
ways to initialize a Scanner is by passing an
InputStream object, like System.in, to the
Scanner constructor.
- String name = scanner.nextLine(); reads
the entire line of text (the user's name) into the
name variable.

École, étude et sujet

Établissement
WLU CP213
Cours
WLU CP213

Infos sur le Document

Publié le
15 octobre 2025
Nombre de pages
16
Écrit en
2025/2026
Type
Examen
Contenu
Questions et réponses

Sujets

15,57 €
Accéder à l'intégralité du document:

Garantie de satisfaction à 100%
Disponible immédiatement après paiement
Lire en ligne ou en PDF
Tu n'es attaché à rien


Document également disponible en groupe

Faites connaissance avec le vendeur

Seller avatar
Les scores de réputation sont basés sur le nombre de documents qu'un vendeur a vendus contre paiement ainsi que sur les avis qu'il a reçu pour ces documents. Il y a trois niveaux: Bronze, Argent et Or. Plus la réputation est bonne, plus vous pouvez faire confiance sur la qualité du travail des vendeurs.
smartzone Liberty University
S'abonner Vous devez être connecté afin de pouvoir suivre les étudiants ou les formations
Vendu
3291
Membre depuis
6 année
Nombre de followers
2295
Documents
14607
Dernière vente
16 heures de cela
AMAIZING EDUCATION WORLD

GET ALL KIND OF EXAMS ON THIS PAGE ,COMPLETE TEST BANKS,SUMMARIES,STUDY GUIDES,PROJECT PAPERS,ASSIGNMENTS,CASE STUDIES, YOU CAN ALSO COMMUNICATE WITH THE SELLER FOR ANY PRE-ORDER,ORDER AND ETC.

3,7

598 revues

5
266
4
94
3
104
2
31
1
103

Récemment consulté par vous

Pourquoi les étudiants choisissent Stuvia

Créé par d'autres étudiants, vérifié par les avis

Une qualité sur laquelle compter : rédigé par des étudiants qui ont réussi et évalué par d'autres qui ont utilisé ce document.

Le document ne convient pas ? Choisis un autre document

Aucun souci ! Tu peux sélectionner directement un autre document qui correspond mieux à ce que tu cherches.

Paye comme tu veux, apprends aussitôt

Aucun abonnement, aucun engagement. Paye selon tes habitudes par carte de crédit et télécharge ton document PDF instantanément.

Student with book image

“Acheté, téléchargé et réussi. C'est aussi simple que ça.”

Alisha Student

Foire aux questions