GRADE - 9 - Introduction To Programming Languages
GRADE - 9 - Introduction To Programming Languages
Program: -
Assembly Language:
Programming Paradigm
Programming paradigm is an approach to programming and refers to the
style of writing programs. Computer program consists of 2 elements -
code and data. A program can be conceptually organized in two ways
that is around its code or around its data.
The two types of programming languages are: -
Procedure Oriented Programming.
Object Oriented Programming.
Procedure Oriented Programming:-(Organised around process)
Developing a program with process centric approach is called Procedure
Oriented Programming. It uses a list of instructions to tell the computer
what to do step by step. The problem is divided into small programs
called functions(procedures or subroutines). The primary focus stays on
the functions which will be used to accomplish the task. Procedures are
implemented on the data to perform the program hierarchy. A program
written in procedural language contain one or more procedures.
Example:- BASIC, Pascal, Fortran.
Limitations:-
The focus is on processing, the emphasis is on doing things.
Procedural languages are difficult to relate with the real-world
objects.
As the code gets larger, maintenance of the program becomes a
problem.
Most functions share global data leaving data at risk of corruption.
The module in a procedural language is dependent on each other so
that reusability is restricted.
Procedural language code is not flexible to change. Since they are
interlinked the complete program should be changed if there is any
error.
Object Oriented Programming:-( Organised around data)
The object-oriented approach views a problem in terms of objects
involved rather than procedure for doing it. An object can be considered
as a partitioned area of computer memory that stores data and a set of
operations that can access that data.
Advantages: -
Any real-world entity can be modelled using Object Oriented
Programming language.
In Object Oriented Programming, the objects are built up in such a
that it can be used in other programs as well. So, it ensures
reusability.
Programs written using OOP language are simpler to change when
the requirements for the application change.
An object wraps the data and methods and ensures data security.
Principles of Object Oriented Programming: -
1) Abstraction: -
Abstraction refers to the act of representing the essential features of a
system hiding the implementation details to the user. This reduces the
complexity and increases the productivity. For example, in a switchboard
only the essential aspects to operate the switchboard is available to the
user hiding the internal circuitry, connections etc.
2) Encapsulation:
The wrapping of data and function that operate on the data into a single
unit(called class) is known as encapsulation. The only way to access the
data is provided by the functions. These functions are called member
functions or methods in java. Access restriction to class members and
methods is provided with the use of access specifiers.
The primary benefit of Encapsulation is
Data Hiding: -
The binding of data and the code that manipulates keeps them safe from
outside interference and misuse. Access to the data is controlled
through an interface.
3) Polymorphism: -
Polymorphism (from Greek meaning “Many Forms) is the concept that
supports the capability of an object of a class to behave differently in
response to a message or action. Polymorphism is the capability of an
interface to do different things based on the data of different type it
accepts and gives the desired output.
Polymorphism is implemented through function overloading and
overriding.
An example from real life : A student in a school is a son/daughter at
home, a player in the game, a customer in the shop,…..
4) Inheritance:-
It is the feature of programming language in which an object can acquire
the properties of another object. The class whose property is acquired is
called super class(Base class or main class or parent class). The class in
which the property of the base class is acquired is called derived
class(Extended class or sub class or child class).
Define class
A class is a template or blueprint used to create multiple instances called
objects that share the common characteristics and behaviour. The
characteristics of an object are represented by its data called attribute
and its behaviour is represented by its associated functions.
Define Object.
Objects are the basic runtime entities in an Object Oriented
Programming language. It represents an entity that can store data and
has its interface through functions. It is also called as an instance of a
class having its own unique identity.
Explain Ordinary Compilation.
The process of converting a source code(program written in high level
language) into the machine code is called compilation. The converted
machine code is dependent on the platform it is executing on. The
resultant machine code is called native executable code. The native
executable code is directly executed on the corresponding computer for
which it has been created.
Explain java compilation.
Programs written in java are compiled into a special type of intermediate
code called byte code using the java compiler, javac. Byte code still
needs an interpreter to execute them on any given platform. Java Virtual
Machine(JVM) is an abstract machine designed on the top of the existing
processors that helps to convert the byte code to the native executable
code and executes it. It generally starts compiling the entire byte code
at runtime using Just-in-time compiler. It hides the underlying Operating
System from java applications. JVM is written specifically for the specific
Operating System which can interpret any byte code for the given
platform.
Explain byte code.
Java byte code is a set of pseudo-machine language instructions that are
understood by the JVM and are independent of the underlying
hardware.
Java byte code is executable by JVM which reads each instruction of the
program one by one and translates it to the corresponding machine
language and executes it.