You are on page 1of 7

Reasons for Studying Concept of ● Marketing SQL - great for data

Programming Language analysis


● Science MATLAB - Built to
1. Increased Capacity to Express Compute with added functionality
Ideas
2. Improved Background for
Choosing Appropriate Languages Programmer - code a program using
3. Increased Ability to Learn New subprog, statements, condition,
Languages declaration
4. Better Understanding of the
Significance of Implementation Translator - Programming language as
5. Better Use of Languages that collection of symbols made up of
are already known thousands of characters
6. Overall Advancement of
Computing
Programming Language Syntax
Areas and Industries of Programming Syntax - Structure of programs without
Language Application any consideration of their meaning
In General Categorization:
● Scientific Applications Key Criteria Concerning Syntax:
● Business Applications ● Readability - Algorithm and data
● Artificial Intelligence are apparent in inspection
● Systems Programming ● Write-ability - easy to write
● Web Software program
● Verifiability - Ability to prove
In specific Industries: program correctness
● Automotivve - C/C++ - Widely ● Translatability - Ease of
used Coding Languages for Car translation the program into
Manufacturers executable form
● CyberSecurity - JavaScript - Solid ● Lack of Ambiguity - Avoiding
Foundation of Software Engineers ambiguous structures
● E-Commerce - Java - Powerful on
finding fixes and debugging\ Basic Syntactic Concepts:
● Engineering - Objective-C - Object Character Set - symbols, letters, and
based digits
■ (MATLAB close Identifiers - strings of letters or digits
runner-up Operator Symbols = + / - *
for engineers) Keywords or Reserved Words - part of
● Finance/Healthcare - Python (Can the syntax of the programming language
be used in Conjunction with Noise Words - can be inserted into
frameworks like DJANGO) statements to improve readability and
● IT & Cloud-Based Solutions: SQL comprehension
used for Cloud Computing/Data Comments - used to improve the
Management readability/For Documentation
Blanks/Whitespace - Significant in literal Stages in Translation
strings Lexical Analysis (Scanning) Identifying
Delimiters - used to denote the the tokens of programming language
beginning and the end of syntactic
constructs. Syntactic and Semantic Analysis
Expressions - functions that access data Syntactic Analysis (Parsing) -
objects in a program and return a value. Determining the structure of program as
Statements - describe a task to be defined by language grammar
performed Semantic Analysis - Assigning meaning
to the syntactic structures.
Overall Program/Subprogram Structures:
Synthesis of the Object Program:
1. Separate subprogram definitions: C
and C++. You write the code for different Three Main Steps:
parts of the program in separate files, Optimization - Removing redundant
and then put them together to create the Statements
final program. Code Generation - Generating assembler
commands
2. Separate data definitions: OOP. You Linking and Loading - Resolve the
can use the object and its methods (the address and obtain the executable code
things it can do) without knowing how it of program
works internally.
Bootstrapping - Compiler, can be written
3. Nested subprogram definitions: in the same language
Pascal. You can build up the program in
layers, using different subprograms for Translates some internal
different parts.
Translated into Assembler and then into
4. Separate interface definitions: C and Machine Language
C++. The header files contain the
instructions for how to use a particular History of Java Programming
library or module.
Originally design for interactive TV
5. Data descriptions separated from James Gosling, Mike Sheridan, Patrick
executable statements: COBOL. The data Naughton - Initiated the language in June
is organized in a separate section so it's 1991
easier to find and use. It was design for small, embedded
systems
6. Un-separated subprogram definitions: It was called "Greentalk by James
BASIC. The code for the main program Gosling, file extension was .gt
and the subprograms is all mixed up After that it was called "Oak" and
together, making it harder to read and developed as part of the Green Project
understand. 1995 Oak renamed as "Java" since it was
already a trademark by Oak Industries
Java - Island in Indonesia where first - lack of pointers
coffee produce (Java Coffee) - Provides automatic garbage
1995 - TM called Java as one of the "10 collection
Best Products of 1995
JDK 1.0 released on Jan 23 1996 Architecture-Neutral - No implementation
dependent features
Java - Used in Windows App, Web App,
Enterprise app, Mobile app, cards, etc Portable - Carries the Java bytecode to
any platform
Features of Java Programming
Language High-Performance -Faster than other
Interpreted programming lang., since
Primary objective is to make it portable, Java Bytecode is "close to native code"
simple, and secure
Distributed
Features of java is also known as "Java Facilitates users to create distributed
Buzzwords" application in Java

Simple - Easy to learn, syntax is simple, RMI/EJB used to create distributed


clean, and easy to understand applications (This makes us able to
access files)
Object-oriented - Organize software as a
combination of different types of objects Multi-Threaded - Write Java programs
that deal with many task at once
Platform Independent - Write once, run
anywhere language Dynamic - Classes are loaded on
demand, also supports functions from
Secured - Java known for its Security its native languages i.e., C and C++

- No explicit pointer public class


- Run inside a virtual machine ● initial class of the program
sandbox ● basic unit of every java program
- Classloader - part of the JRE
used to load java classes into Java {}
Virtual Machine ● class is delimited by braces
- Bytecode Verifier - checks the
code fragments for illegal code public static void main(String[] args)
- Security Manager - determines ● method inside a class
what resources a class can access ● first to run in every execution

Robust - English meaning of Robust is Comments - for reader not for the
Strong compile

- Uses strong memory management Special Symbols:


● Mathematical Symbols Boolean - Deals with logical values (True
● Punctuation Marks or False)
● Token - made up of two
characters but regarded as a Java represent decimal numbers using
single symbol Float and Double

Reserved Words: Float - memory 4 bytes


int, float, double, char, void, public, max values is 6 or 7
static, throw, return
● Also called keywords Double - memory 8 bytes
● Always in lowercase max values is 15
● Considered a single symbol
● Cannot be redefined Arithmetic Operators
● Cannot be used for anything than ● Addition
their intended to use ● Subtraction
● Multiplication
Identifiers: ● Division
Third Category of token that could be ● Mod
name of Variables, Methods etc.
Order of precedence - left to right
Data Types - Set of values together
Input - must be loaded into main memory
Primitive Data Types: before it can be manipulated
Fundamental Data Types:
Storing Data in the Computer's memory:
Integral - deals with integers and 1. Instruct the computer
numbers 2. Include statements
● char 2(16 bits)
● byte 1 (8 bits) Named Constant - not allowed to change
● short 2 (16 bits) during execution
● int 4 (32 bits)
● long 8(64 bits) Putting Data into Variables:
1. Assignment Statement
int Data type - do not require + sign in 2. Use input (Read) statement
front
no commas are used for separating Output - Using the standard output
items object system.out

char Data type - single character System.out - print/println

Floating point - Deals with decimals Packages - collections of libraries and


- floating-point notation related classes
Classes - used to group a set of related Expression is usually an identifier
operation
- allow users to create their own Why Repetition needed? - It enhance the
data type capabilities of the programs by allowing
to repeatedly execute instructions
Control Structures - provide alternatives
to sequential program execution Java Three repetition/Looping
- alter flow of execution Structures:
1. While
Most common control structures are 2. For
selection and repetition 3. Do While

Selection - executes particular statement While Loop - be either a simple or


depending on one or more condition compound statement

Branch - Altering the flow of execution Counter-controlled While Loops - while


by making a selection/choice loop assumes the form of a
counter-controlled while loop
Repetition - Repeat particular statement
depending on one or more condition Sentinel-Controlled while Loops - The
statements need to be executed until a
Loop - Altering the flow of execution by special values are met. This special
repetition of statements(s) value is called a sentinel.

One-way Selection - Incorporate using Flag-Controlled while Loops - uses a


the if statement boolean variable to control the loop.

Two-way Selection - choose between two EOF-Controlled While Loops - Since


alternatives: if and else programmers sometimes do not know
what sentinel is. you can use an EOF
Multiple Selection Nested if (End Of File)-controlled while loop.
Implementing more than two
alternatives, else if Expression-Controlled while Loops:

Conditional Operator (?:) - ternary for Looping (Repetition) Structure -


operator which takes three arguments general form of the for statement is:
for (initial expression; logical
Switch Structures - 3rd Selection expression; update expression
structure which does not require the statement)
evaluation of a logical expression
In Java, for is a reserved word. The
Reserved words in Java: switch, case, logical expression is called the loop
break, default condition.
For loop - used to implement After the break statement executes, the
counter-controlled loops. program continues to execute
- typically called a count or starting at the first statement after the
indexed for loop. structure.

In Java, do is a reserved word. As with The use of a break statement in a loop


the other repetition structures the can eliminate the use of certain Boolean
do...while statement can be either a variables.
simple or compound statement
File Input/Output Operation - If the
If a compound statement, enclose it amount of input data is large, it is
between braces. inefficient to type

Choosing the right Looping Structure: ● Sending output to the screen


works well if the amount of data is
● For loop - If you know the small
program can determine in
advance ● use an alternate form of input and
output: files.
● While loop - If you do not know,
and the program cannot file is defined as follows:
determine in advance, File - An area in secondary storage used
to hold information.
● do...while loop - If you do not
know, and the program cannot ● Reading data from a file
determine in advance, the number
of repetitions needed, and it is at we use the class FileReader as follows:
least one ● The class FileReader is contained
in the package java.io. Suppose
Nested Control Structures that the input data is stored in a
file, say, prog.dat.
Looping Flow Control -The break and
continue statements alter the flow of ● Storing (Writing) Output to a File -
control in a program To send the output to a file, you
- The break and continue use
statements alter the flow of ● the class PrintWriter. This class is
control in program contained in the package java.io

break statement is typically used for two Java file I/O is a four-step process:
purposes: 1. Import classes from java.util
● To exit early from a loop and java.io packages
● To skip the remainder of the 2. Create objects and associate
switch structure them with input/output sources
3. Use appropriate methods to ● The index specifies the position
input/output the data of the element in the array.
4. Close the files. ● In Java, array indices start at 0,
Use PrintWriter to send output to and the [] operator is used for
a file array subscripting.

Array Utilizing Arras on Data Types


● fixed-size collection of variables Java Arrays can be utilized on the
all of the same data type following Data Types:
● Array elements are stored in ● Integer Array
contiguous memory locations ● Java Double Array
● One-dimensional arrays have ● Byte Array
elements arranged in a list ● Boolean Array
● Character Array
A. Advantages of arrays: ● Java Array Of Strings
● Code optimization for efficient ● Empty Array In Java
retrieval and sorting of data
● Random access to data by index
position

B. Disadvantages of arrays:
● Limited size, cannot grow at
runtime
● Collection framework is used to
solve this problem

C. Types of arrays:
● Single-dimensional array
● Multidimensional array

D. Examples
The statement:
int[] num = new int[5];

E. Alternate ways to declare Arrays


Java allows you to declare arrays as
follows:
int list[]; //Line 1

F. Accessing Array Elements


● Array elements are accessed
using an index, which is a
non-negative integer less than the
size of the array.

You might also like