Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

Class notes (Java)

Rating
-
Sold
-
Pages
36
Uploaded on
06-05-2024
Written in
2023/2024

Providing knowledge about the basics of java to the engnieering students and to help them to gain skills in basics of java

Institution
Course

Content preview

Programming in Java ****** 18CS653




MODULE 1



An Overview of Java:

 Object Oriented Programming
 A First Simple Program
 A Second Short Program
 Two Control statements
 Using Blocks of code
 Lexical Issues
 The Java Class Libraries

Data Types, Variables and Arrays:

 Java is a Strongly typed Language
 The Primitive types.
 Integers
 Floating-Point types
 Characters
 Booleans
 A Closer look at Literals
 Variables
 Type conversion and casting
 Automatic Type promotion in Expressions
 Arrays
 A few words about strings




Mrs.Mamatha A, Assistant Professor, ISE Department 1

,Programming in Java ****** 18CS653



Object Oriented Programming:
 Object oriented programming (OOP) is the core of Java programming.
 Java is a general purpose, object- oriented programming language developed by Sun
Microsystems. It was invented by James Gosling and his team and was initially called
as Oak.
 The most important feature that made Java very popular was the ―Platform-
Independent‖ approach.
 It was the first programming language that did not tie-up with any particular operating
system( or hardware) rather Java programs can be executed anywhere and on any
system.
 Java was designed for the development of the software for consumer electronic
devices like TVs, VCRs, etc.
Two Paradigms:
 Every program contains 2 components code and data.
 Two approaches are there to solve the problem and in program writing: Procesure
oriented and object oriented.
Procedure Oriented:
 Procedure oriented programs are written based on ―whats happening‖ around, where
the code acts on data. Ex: C etc
 Problems increases in procedure oriented as the program grows larger and more
complex.
Object Oriented:
 Object oriented programs are written based on ―Who is being affected‖ around,
which manages the increasing complexity.
 It organises program around data and well defined interfaces of that data.
 Characterised as data controlling access to code. Ex: C++, JAVA, Small Talk etc


The Three OOP:
The three important features of OOP are:
 Encapsulation
 Inheritence
 Polymorphism


Mrs.Mamatha A, Assistant Professor, ISE Department 2

,Programming in Java ****** 18CS653


Encapsulation:
 Encapsulation is the mechanism that binds together code and data it manipulates,
and keeps both safe from outside interference and misuse.
 In Java the basis of encapsulation is the class. A class defines the state and behavior(
data & code) that will be shared by set of objects.
 Each object contains the structure and behavior defined by the class. The data
defined by the class are called instance variables(member variables), the code that
operates on that data are called methods(member functions).


Inheritence:
 Inheritence is the process by which one object acquires the properties of another
object. This is important as it supports the concept of hierarchical classification.
 By the use of inheritence, a class has to define only those qualities that make it
unique. The general qualities can ber derived from the parent class or base class.
 Ex: A child inheriting properties from parents.


Polymorphism
 Polymorphism (meaning many forms) is a feature that allows one interface to be
used for a general class of actions. The specific action determined by the exact
nature of the situation. This concept is often expressed as ― one interface, multiple
methods‖.
 Ex: ―+‖ can be used for addition of 2 numbers and also concatenation of 2 strings.
System.out.println(2+4); // outputs 6 as answer
System.out.println(―Hello‖ + ―Gautham‖); // outputs Hello Gautham as answer


Apart from this the additional features include:


Object:
 An object can be any real world entity.
 Ex: an animal, bank, human, box, fan etc
 An object is a software bundle of related state and behavior.
 An object is an instance of class.




Mrs.Mamatha A, Assistant Professor, ISE Department 3

, Programming in Java ****** 18CS653


Class:
 A class is a blueprint or prototype from which objects are created.
 Its just a template for an object, which describes an object.
 Ex: a class describes how an animal looks like.
 A class is a user defined data type.


Abstraction:
 Data abstraction refers to providing only essential information to the outside world
and hiding their background details i.e., to represent the needed informatin in
program without presenting the details.
 Ex: a database system hides certain details of how data is stored and created and
maintained.


Polymorphism, Encapsulation and Inheritence work Together
 The 3 principles of OOP Polymorphism, Encapsulation and Inheritence combines
together to make the programming robust and scalable.
 Encapsulation allows to migrate the implementation without disturbing the code that
depends on class.
 Polymorphism allows to create clean, sensible, readable, resilient code.
 Inheritence mainly deals with the code reusability.


A First Simple Program

class Example
{
public static void main(String args[])
{
System.out.println(―Welcome to Programming in Java‖);
}
}


1. Open the notepad and type the above program



Mrs.Mamatha A, Assistant Professor, ISE Department 4

Written for

Institution
Course

Document information

Uploaded on
May 6, 2024
Number of pages
36
Written in
2023/2024
Type
Class notes
Professor(s)
Suresh
Contains
All classes

Subjects

$14.76
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
supriyahiremath

Get to know the seller

Seller avatar
supriyahiremath RYMEC BELLARY
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
2 year
Number of followers
0
Documents
5
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions