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

Computer Notes

The document provides an introduction to Java programming, defining key concepts such as class, object, abstraction, encapsulation, inheritance, polymorphism, and data types. It explains the features of Java, including its platform independence and the role of the main method in program execution. Additionally, it covers operators in Java, detailing arithmetic, relational, logical, assignment, and conditional operators, along with their precedence and associativity.

Uploaded by

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

Computer Notes

The document provides an introduction to Java programming, defining key concepts such as class, object, abstraction, encapsulation, inheritance, polymorphism, and data types. It explains the features of Java, including its platform independence and the role of the main method in program execution. Additionally, it covers operators in Java, detailing arithmetic, relational, logical, assignment, and conditional operators, along with their precedence and associativity.

Uploaded by

prayanmishra.pm7
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Chapter 1: Introduction to JAVA

Define
1) Class – Class is a group of objects that have some common attributes and behaviour
Eg. Fruit is a class and orange is an object that belongs to it.
2) Object – An object is an identifiable entity with some attributes and behaviour.
3) Abstraction – Abstraction refers to the act of representing essential features without
including background details.
Eg. ATM Machine
4) Encapsulation – Encapsulation is a mechanism that binds data and code together into
one unit. It keeps them safe from the outside world, preventing any unauthorised access.
5) Inheritance – Inheritance is a powerful mechanism by which one class acquires the
properties of another class.
6) Polymorphism – Polymorphism refers to the ability of an object to take different
forms.
7) Constants – These are values that remain fixed and do not change in the program.
8) Variables – Variables represent reserved memory locations containing data values.
9) IDE – IDE is a software suite with programming facilities like GUI builder, code
editor, compiler, interpreter and debugger used by software developers through a
graphical user interface. Eg BlueJ is an IDE for Java.
10) Token – Java tokens are the basic building blocks of a Java program. They are the
smallest unit of a java program.
They are of 5 types:
● Keyword
● Identifiers
● Literals
● Operators
● Separators
11) Keywords – Keywords also called Reserved Words, are the words that have a special
meaning to Java compilers. Eg if, int
12) Identifiers – Identifiers are used to name different components of a program such as
variables, methods,etc. Two rules for writing identifiers are :
● An identifier cannot begin with digit
● Java is case sensitive, which means that two identifier names that differ only in
upper and lower case characters are considered to be different identifiers.
13) Literals – Literals are the values stored in variables. Literals are made of digits,
letters and other characters.
14) Separators : Separators in a programming language are used to separate program
elements from one another.Example: semicolon
15)Data type – Data types represent the type of value stored by a variable. They are of
two types.
● Primitive data type – They are simple, predefined data types supported by Java.
There are eight primitive data types . For example:int,float
● Non Primitive data type – The data types that are derived from primitive data
are called non primitive data types. They are also called reference data types.
For example:Array and Class
16) Procedure-oriented programming language follows a top-down approach in
execution. A group of instructions is organised into functions that can be reused. Data is
accessed by functions.
17) An object-oriented programming language follows a bottom up approach and is
based on the concept of objects. Objects are small segments of code that contain
functions to perform a task on a given data. Eg C++ and Java .

Features of JAVA are:-


1) Java is simple and platform independent
2) Java achieves platform independence by using both interpreter and compiler.
Q1) Why is JAVA called a platform Independent language?
A1) Java is a high level object oriented programming language. The Java compiler first
converts the source code into an intermediate language binary form called bytecode,
which is machine independent. Java interpreter, also called JVM( Java virtual
machine), converts the bytecode into machine code to run on an operating system.

Q2) What is the method and main method?


A2) In Java, functions are referred to as methods. A Java program contains one unique
method called main method by which the execution of any application begins.

Q3) What are comments ?


A3) Comments are statements that are not executed by the compiler and they provide
information about the program. They are of 3 types: single line, multiline and
documentation.
Important:

Types Size

Byte 8 bits

Short 16 bits

Int 32 bits

Long 64 bits
Float :32 bits
Double:64 bits
char :16 bits

Chapter 2: Operators In JAVA


Operators are symbols used to perform arithmetic or logical operations on given
expressions. The variables or literal on which an operator is applied are called
operands.
Forms of operators
● Unary operators – A unary operator requires only one operand. Unary operators
are +,-.++,- -,!
● Binary operators – A binary operator requires two operands +,%,>,&&.
● Ternary operators – A ternary operator requires three operands.

Q1) What are Arithmetic Operators ?


A1) Arithmetic operators are used to perform basic mathematical calculations like
addition(+), subtraction(-), multiplication(*), division(/) and modulus(%).

Q2) What are Relational Operators?


A2) Relational operators determine the relationship that one operand has to the other.

Operator Symbol

Greater than >

Less than <

Equal to ==

Greater than or equal to >=

Less than or equal to <=

Not equal to !=

Q3) What are Logical Operators?


A3) Logical operators operate only on boolean operands and are used to construct
complex decision making expressions.

Operator Symbol

Logical AND &&

Logical OR ||

Logical NOT !

Q4) What are Assignment Operators?


A4) Assignment operators are used to assign a value to a variable.
For eg. A=10

Q5) What are Conditional Operators?


A5) The Conditional operators in Java are also known as boolean operators that
evaluate multiple conditions in expressions and return Boolean values (true/false) as
result. Conditional operators are classified into AND, OR and ternary (?:) operators.
Ternary operator: It has three operands.
Syntax: boolean-expression? expression1: expression2. First of all, it evaluates the
boolean- expression which basically is a conditional statement. If it is true then the value
of the expression is expression1, otherwise the value of the entire expression is
expression2.

Q6) What is Precedence and Associativity?


A6) Precedence – It is the priority of an operator according to which it is evaluated.

Associativity – If two operators have the same precedence they are either evaluated
from "left to right" or from "right to left" this term as associate which tells the
direction of execution of operators when operators in an expression have the same
precedence.

Q7) Differentiate between ‘==’ and ‘=’


== =

It is a relational It is an assignment operator.


operator

It is used to compare two values. It assigns a value to a


variable.

All the best.

You might also like