Computers
Computers
Computers
COMPUTER
APPLICATION
CONCEPTS RECAPTULATION
▪ Types of memory
▪ Process of booting -BIOS
▪ Operating System role
▪ Programming language
▪ Types of Languages –Binary, Assembly and HLL
And their characterictics /Disadvantages
▪ Translators/Language Processors –Compilers and
Interpreters(differences )
▪ Source code : definition
▪ Object code/Machine code/Binary code
:Definition
Chapter 3
Values and Data types
CHARACTER SET IN JAVA
•Letters
•English alphabet (A-Z,a-z)
•Digits
•0-9
•Delimiters
•Special characters
•Operators
•Arithmetical , logical and relational
▪ public class JavaProgram
▪ {
▪ public static void main(String args[ ])
▪ {
▪ int len, bre, peri, area;//declaring the TOKEN
variables
▪ len=6;
▪ bre=10;
▪ peri=0;
▪ area=0;
▪
▪ area = len*bre;//calculating area
▪ peri = (2*len) + (2*bre);//calculatig perimeter
▪
▪ System.out.print("Area = " +area);//displayig area
▪
▪ System.out.print("\nPerimeter = " +peri);//
▪ }}
▪
TOKEN
•Literals
•Identifiers
•Assignment
•Punctuators
•Seperators
•Operators
•Keywords
CHARACTER SET IN JAVA
•Letters
•English alphabet (A-Z,a-z)
•Digits
•0-9
•Delimiters
•Special characters
•Operators
•Arithmetical , logical and relational
Literals(Constants)
•9.089823
•Character
•All alphanumeric
•String
•Set of characters
•“sdhfjdh”
•Hello8989”
•“10% of amount “
•Boolean
•true or false
•Null
Punctuators
▪ Reserved words
▪ Special meaning in the system compiler
▪ Keywords cannot be used as variable names
▪ Eg:
public
Class
for
System etc
Assignment
=
Various types of Token
•Literals
•Identifiers/Variables
•Assignments
•Punctuators
•Seperators
•Operators
•Keywords
VARIABLE ????
Identifiers(variables)
▪ Syntax;
<data type> <space> <var name>;
Eg:
Int a,b,c;
Need to declare the
variable
?
Rules for naming a variable
•float
FLOATING POINT •double
---with decimal numbers
Character data type
▪ byte
▪ char
▪ short
▪ int
▪ long
▪ float
▪ double
▪ What do you mean by data type?
▪ State two kinds of data types.
▪ What do you understand by primitive data
type? Give two examples.
▪ What do you mean by non-primitive data
type? Give examples.
▪ Why is it necessary to define data type in Java
programming?
▪ What is the hierarchy of data types?
(Y+Z/8)*78
Arithmetic expression????????
x+y
Arithmetic statement?????????
Z=x+y
▪ int a,b,c,d;
d= a+b+c;
Pure Impure/mixed
▪ Implicit Explicit
IMPLICIT/coersion
int a, b;
float c=(float)(a+b);
Resultant datatypes? After
type conversions
int i;
float f; double d;char c; byte b;
a) i+c/d;
b) f/d+c*f;
c) i+f-b*c;
d) (f/i)*c+s;
e) i+f-c+b/d;
f) i/c+f/b;
Escape sequences
Output:
USA
Uk
UNICODE and ASCII code
▪ Fundamentally, computers just deal with numbers.
▪ They store letters and other characters by assigning a number for each
one.
▪ Before Unicode was invented, there were hundreds of different systems,
called character encodings, for assigning these numbers. These early
character encodings were limited and could not contain enough characters
to cover all the world's languages.
▪ Even for a single language like English no single encoding was adequate
for all the letters, punctuation, and technical symbols in common use.
▪ Early character encodings also conflicted with one another. That is, two
encodings could use the same number for two different characters, or use
different numbers for the same character.
▪ Any given computer (especially servers) would need to support many
different encodings. However, when data is passed through different
computers or between different encodings, that data runs the risk of
corruption.
▪ System. out. print(" Want \t to\t learn \t
computers");
•128 characters(0-127)
•0-9 48-57
•A-Z 65-90
•a-z 97-122
Operators and
Expressions in
Java
X=Y+Z+8
operands
variables Constant
X=Y+Z+8
Operators
Arithmetic expression????????
x+y
Arithmetic statement?????????
Z=x+y
ARITHMETIC
EXPRESSION
v/s
JAVA EXPRESSION
Area=2(l+b)
Area=2*(l+b)
▪ Abc
▪ ab-bc+ac
▪ (p*r*t)/100
OPERATORS
x=x*2
x*=2
A short hand expression is formed only when a
variable is used as an accumulator to the
expression(same variable before and after
assignment operator.
Arithmetic operators
If( (a+b)>c)
{
K=15;
S.O.P(k);
}
else {
K=30;
S.O.P(k);
}
NESTING
▪ a,b,c
Relational Operator
▪ (3>5)&&(7>9)------
Logical OR
▪ (3>5)||(7>9)------
LOGICAL NOT !
▪ !(8>9)----
ENCAPSULATION
The concept of hiding
internal details and exposing
external details is called
ABSTRACTION
OBJECT AND CLASSES
STEPS TO CREATE OBJECT
CLASSNAME OBJECT
DECLARATION
NAME
INSTANTIATION
INITIALISING
VARIABLES
CLASS/OBJECT TERMS