Skip to content

Instantly share code, notes, and snippets.

View Kev-in123's full-sized avatar
🎯
Focusing

Kevin Kev-in123

🎯
Focusing
View GitHub Profile
@Kev-in123
Kev-in123 / Notes.txt
Last active January 12, 2022 21:47
Quiz: OOP
Access Control:
private - can only be accessed in the class
protected - can only be accessed in the class or a subclass
public - can be accessed anywhere
Modifiers:
abstract - a non-access modifier, used for classes and methods
final - a non-access modifier used for classes, attributes and methods (not changeable)
finally - executes no matter if the try-except failed or passed
native - specifies that a method is not implemented in the same java source file
@Kev-in123
Kev-in123 / Notes.txt
Last active July 1, 2023 02:41
Test: Selection & Repetition
Data types (probably useless but since there is a coding portion, I'm including them anyways):
boolean - stores true or false
byte - stores whole numbers from -128 to 127
char - stores a single character/ASCII values
int - stores whole numbers from -2,147,483,648 to 2,147,483,647
long - stores whole numbers from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
short - stores whole numbers from -32,768 to 32,767
float - stores fractional numbers, sufficient for storing 6 to 7 decimal digits
double - stores fractional numbers, sufficient for storing 15 decimal digits
@Kev-in123
Kev-in123 / Notes.txt
Last active December 27, 2021 00:16
Quiz: Java Basics
Non-numerical math values in java:
n/0.0 = Infinity where n is a positive number
n/0.0 = -Infinity where n is a negative number
0/0.0 = NaN (can also do 0.0/0.0)
note the 0.0 is a decimal and not an integer
Operators:
+ adds the numbers
- subtracts the numbers
* multiplies the numbers
@Kev-in123
Kev-in123 / ArrayExamples.java
Last active December 27, 2021 00:16
Test: Arrays & File I/O
public class ArrayExamples {
public static void main(String[] args) {
// create an array of integers of length 10
int[] arr = new int[10];
// store the size of the array in a variable
int len = arr.length;
// use a for-each loop to
for (int i: arr) {
System.out.println(i);
// the output will be 10 lines of 0s since we haven't modified it
@Kev-in123
Kev-in123 / MethodExamples.java
Last active December 27, 2021 00:16
Test: Strings & Methods
//Some of these may have errors as i was too lazy to check if they work or not
//Recursion exsists in java but i'm not adding them in these notes
public class MethodExamples {
//the main method, the entry point of the program
//methor name: main
//return type: N/A
//parameters: String[] args
public static void main(String[] args) {
System.out.println("Hello World");
@Kev-in123
Kev-in123 / Notes.txt
Last active March 27, 2023 22:54
Quiz: Selection
|| - or
&& - and
! - not
switch - The expression is compared with the values of each case, if none match, then the default is used, if there isn't a default, nothing happens
case - Used in a switch-case statement to specify a case
default - The default block of code in a switch statement, if it's the last statement, it doesn't need a break
Notes on switch-case statements:
- The variable used in a switch statement can only be an integer/byte/short/char/strings/enums