0% found this document useful (0 votes)
3 views

assignment fundamentals of programming

The document outlines the fundamentals of programming in Java, covering key topics such as basic data types, collections framework, file I/O, and error handling. It also discusses variable assignment, reading, arithmetic operations, and object instantiation, emphasizing the importance of type compatibility and the use of constructors. Additionally, it highlights potential issues like overflow, underflow, and null references in Java programming.

Uploaded by

kbofficial555
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

assignment fundamentals of programming

The document outlines the fundamentals of programming in Java, covering key topics such as basic data types, collections framework, file I/O, and error handling. It also discusses variable assignment, reading, arithmetic operations, and object instantiation, emphasizing the importance of type compatibility and the use of constructors. Additionally, it highlights potential issues like overflow, underflow, and null references in Java programming.

Uploaded by

kbofficial555
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Fundamentals of programming group C assignment

Group C members
 Ashlene Chumilah
 Allamanor Gichuki
 Keegan Mutemi
 Ian Mwangi
 Eunice Njoki
 Dennis Kiprotich
Java Data operations
1. Basic Data Types and variables
-Java supportsprimitive data types like (int,char,float) and objects.
-You can perform operations like add,sub,comparison
2. Collections framework
-java collection provides a flexible way to store and manupulate data.
-common operations includes adding,removing and iterarating
3. File input/output
-Java provides classes for reading from and writing to files ( e.g ,file-reader,file-
writer,e.t.c)
4. Data operations
-java database connectivity (JDBC) is used for database operations.
-you can connect to adatabase, execute queries, and retrive results.
5. Error handling
-use try-catch block to handle expectations that may occur during data
operations
6. Array
-array are a fixed-size data structure that holds elements of the same type.
-examples of operations:initializing,searching and sorting.
7. Streams API
-the streams API alows functional-style operations on collections.
-you can filter,map and reduce data easily.

Variable Assignment
 Declaration and Initialization
o Variables in Java have to be declared before use.
Every variable declaration also includes its type, such as int, double, String.
o Variables can be initialized (assigned a value) at the time of declaration.
o More than one variable of the same data type may be declared and initialized
on one line.
o Repetition
 Reassignment
o Variables may always be reassigned to other values anywhere in the
program.
o The new value must be compatible with the variable's type.

Variable Reading
Variable Value Retrieval
○ Variable Listeners: The values of variables can be read out for use in expressions
or operations.
○ To obtain the value of a variable, its name is used.
Other Reasons
○. It is a compile-time error to read an uninitialized variable.
○ All variables should have some value assigned to them before use.

Variable Arithmetic
 Arithmetic Operators
o Java supports the following arithmetic operators for variables: +, -,
o *, /, and %.
o Arithmetic operations can be performed on numeric variables such as int,
double, etc.
o The result of an arithmetic operation is assigned to a variable.
 Order of Operations
○ Parentheses can be used to indicate order of operations.
○ Java follows the normal order of operations-PEMDAS: Parentheses, Exponents,
Multiplication/Division, Addition/Subtraction.
Overflow and Underflow
○ Addition and subtraction may cause overflow or underflow because the result
may be out of its data type's range.
○ Overflow occurs when the result is greater than the maximum value of that type.
Overflow occurs when a result is greater than the maximum value of its data type.

Object Instantiation
Object Instantiation
In Java, objects are instances of classes instantiated using the new keyword.
The construction of an instance will call a constructor in the class to initialize an
object's state.
○ Constructors may also take parameters for the initialisation of an object's
state.
Object References
○ Objects are of reference types - the variable contains a reference to an object on
the heap.
While multiple variables may refer to the same object.
○ Changing an object via one variable affects the object another variable refers to.
Null References
○ A variable may have the value nil and thus not refer to an object.
○ An attempt to access members (fields or methods) of a null object causes a
NullPointerException.

You might also like