Week2 Student
Week2 Student
Fundamentals of
Computer Programming
ASSEMBLER
We use these to convert low-level languages into machine code.
Example of low-level languages: Machine language and assembly
language
TRANSLATORS - COMPILERS
Program Source
WRITE Code Bytecode
COMPILE RUN
(SOURCE CODE)
The programmer write Java compiler takes java JVM translate bytecode
the code using Java as program as input and into machine language
programming language. generate java bytecode and executes each
as output. program statement as
soon as it is translated.
JAVA BYTECODE
Bytecode refers to a low-level representation of code. It is an
intermediate representation of code that is generated by a
compiler from the source code written by a programmer. It is
not directly executed by the computer's hardware or
operating system, but rather by a virtual machine or
interpreter that understands the bytecode instructions.
SUMMARY:
In summary, the JRE provides the runtime environment to execute
Java applications, the JVM executes Java bytecode and manages
runtime operations, the JDK is used for developing Java applications
and includes the compiler, the compiler translates human-readable
Java source code into bytecode, and the JVM (partly) acts as an
interpreter to execute bytecode efficiently.
SYNTAX ERROR VS LOGICAL ERROR
A syntax error occurs when the code violates the rules of the programming language's
syntax. These rules dictate how statements and expressions should be structured,
including proper placement of brackets, parentheses, semicolons, keywords, and other
language-specific elements.
A logical error occurs when the program's code is syntactically correct but does not
produce the expected output due to incorrect logic or flawed reasoning in the
program's design. Logical errors stem from incorrect algorithmic or logical decisions
made by the programmer.
DEBUGGING
Debugging is the process of finding and fixing mistakes in computer
programs. These mistakes, or "bugs," can cause problems like crashes,
wrong results, or unexpected behavior. Errors can occur due to
various reasons, such as syntax mistakes, logical flaws, incorrect data,
unexpected behavior, or performance issues. Debugging is an
essential skill for programmers to ensure the correctness and
reliability of their code.
Integrated Development Environment
• The answer is we use an IDE (Integrated Development Environment) to
write code
• A place to write, run and debug code and also convert it to machine code
• IDE are like any other program on your computer except used for the
facilitation of code.
• Examples: Netbeans, Eclipse, IntelliJ, visual studios, sublime etc.
• Built in Error-checking
• Auto fill for frequently used words
Remember that computers can only understand and perform the
manipulation of 0’s and 1’s. These 0’s and 1’s are called binary digits.
The smallest unit of information that a computer supports refers to
bits. For the user to communicate with computers, these digits are
being combined to represent a character, number or symbol. As
programmers, it is essential to understand how data is being
translated from one form to another.
BIT vs BYTE
The term "bit" stands for "binary digit." A bit is the smallest unit of data in a
computer and can represent one of two states: 0 or 1. It's like the atom of
computing. Computers process and store information using bits. For instance, a bit
can represent the state of a switch being on (1) or off (0).
A "byte" is a group of 8 bits. It's a fundamental unit of data that's often used to
represent a character, like a letter, number, or symbol. Bytes provide a way to
work with larger pieces of information than just individual bits. A byte can
represent 256 different values (2^8), which includes all the possible combinations
of 8 bits.
NUMBER SYSTEM
NUMBER SYSTEM
long:
• long information sort is a 64-bit marked two’s supplement whole number.
• Maximum value for this data type is 2^63 -1, which is equal to
9,223,372,036,854,775,807.
• Minimum value for this data type is -2^63, which is equal to -9,223,372,036,854,775,808.
This sort is utilized when a more extensive memory range than int is required.
• The default value for those data type is 0l.
• Example: long x = 174636l, int y = -536452l
PRIMITIVE DATA TYPES
float:
• float is a data type, which is know for its solitary exactness, 32-bit IEEE 754 gliding
point.
• float is for the most part used to spare memory in vast exhibits of coasting point
numbers.
• The default value for this data type is 0.0f. float information sort is never utilized
for exact values, for example, money.
• Example: float x = 254.3f
double:
• double information sort is a float with two fold exactness 64-bit IEEE 754 drifting
point.
• This information sort is for the most part utilized as the default information sort for
decimal qualities.
• double information sort ought to never be utilized for exact values, for example,
money.
• The default value for this data type is 0.0d.
• Example: double x = 321.4
PRIMITIVE DATA TYPES
boolean:
• boolean information sort speaks to one bit of data.
• Any boolean variable can assume one of the two values: true or false.
• This information sort is utilized for basic banners that track genuine/false
conditions.
• The default value for this data type is false.
• Example: boolean check = true;
char:
• char information sort is a solitary 16-bit Unicode character.
• Maximum value for a variable of this type is “\uffff” (or 65,535
comprehensive).
• Minimum value for a variable of this type is “\u0000” (or 0).
• char information sort is utilized to store any character.
• example: char text =‘a’
Reference Data Types (Reference Types):
In Java, a reference data type refers to a type that represents
references to objects in memory rather than holding the actual
data directly. These types allow you to work with more complex
data structures and objects. Unlike primitive types that store the
actual value, reference types store a reference or memory
address pointing to the location where the object's data is stored.
REFERENCE DATA TYPES
Reference data types are used to store references to objects, rather
than the actual data.
SYNTAX
Type Variable_1 = Expression_1, Variable_2 = Expression_2,
. . .;
EXAMPLES
int numberSeen = 0, increment = 5;
double height = 12.34, prize = 7.3 + increment;
char answer = 'y';
ANY QUESTIONS?
Fundamentals of Computer Programming
The End