PRESESNTATION
CORE JAVA
Prepared By :Ganesh N.Chittalwar
CONTENTS
 Introduction to core java
 Java features
 Why java is called as platform
 Difference between class and object
 What is class?
 Object.
 Java basic primitive types
 Arrays in java.
 Object oriented programming
 What is the Standard Packages
 Example of Package and library creation
 What make a library package
INTRODUCTION OF JAVA
 Java programming language
 The one we use to write our program
 Compiled to byte code of JVM
 Java virtual machine (JVM)
 Java interpreter – interpret the compiled byte code
 Software simulated CPU architecture
 Cross-platform: support Linux, Windows,
PalmOS…etc.
 Java runtime environment (JRE)
 Predefined set of java classes available to use
 Core Java APIs – basic utilities, I/O, graphics,
network…
FEATURES OF JAVA
The primary objective of Java programming language creation was to
make it portable, simple and secure programming language. Apart from
this, there are also some excellent features which play an important role in
the popularity of this language. The features of Java are also known as
java buzzwords.
WHY JAVA IS CALLED AS “PLATFORM”
A platform is basically the hardware or
software environment in which a program
runs. Java provides software-based platform
i.e. JVM, which can run applications
developed using the Java Programming
Language.
DIFFERENCE BETWEEN CLASS AND OBJECT
class is just a blueprint. A class defines the available characteristics and
behavior of a set of similar objects.
e.g. Car class defined has so many attributes and behaviour such as
start(),stop(),accelerate() etc,
Example:
Public class dog{ <<< dog this is class
String breed;
Int age;
String color;
void barking(){
}
Void hungry(){
}
void sleeping(){
}
}
WHAT IS CLASS?
 Class introduces a new data type
 A class describes a set of objects that have
identical characteristics (data elements) and
behaviors (methods).
 Existing classes provided by JRE
 User defined classes
 Once a class is established, you can make
as many objects of it as you like, or none.
SIMPLE EXAMPLE :CLASS PERSON
 A Person has some attributes
 The class defines these properties for all
people
 Each person gets his own copy of the fields
 Attributes = properties = fields
OBJECT:
object or instance is basic runtime entity. E.g. Maruti Alto, WaganR, Maruti
Swift etc.
Example :
public class Puppy{
Public puppy(string name){
Sop(passed name is:”+name);
}
Public static void main(string[]args){
//this object
Puppy mypuppy =new puppy(“tommy”);
}
}
JAVA BASICS: PRIMITIVE TYPES
 One group of types get special treatment in
Java
 Variable is not created by “new”, not a
reference
 Variable holds the value directlyy77
ARRAY INDEX
 int[] age = new int[5];
The first element of array is age[], second is age[1] and so on.
If the length of an array is n, the last element will be arrayName[n-1]. Since the
length of arr array is 5, the last element of the array is age[4]
The default initial value of elements of an array is 0 for numeric types
and false for boolean.
ARRAY IN LENGTH
 Arrayname.length
 Int s =arr.length;
 if we make for 5 element
 if we need this statement and arraylength
  in the above length show if we create array
that time we don’t know size ..
 And from user any number enter he is don’t
know number any number entered there no fix.
he is don’t know his size …for this know size
that time using arraylength also use for.. loop.
OBJECT ORIENTED PROGRAMMING
Object-oriented programming (OOP) is a
programming based on the concept of
"objects",
which are data structures that contain data, in
the form of fields, often known as attributes
and code in the form of procedures, often
known as methods.
JAVA OBJECT ORIENTED
 Inheritance
 Abstraction
 Encapsulation
 Polymorphism
 Interface
 packages
INHERITANCE
inheritance is a way implement IS-A relationship.
Subclass inherits the super class properties like ..data
member, method.inheritance is the way of resusebility of
code
.
Example :
class student {
…..
Public class collagerstudent extends student{
…
Show method(){
}
}
ABTRACTION
Abstraction is a process of hiding the implementation
details from the user. Оnly the functionality will be provided
to the user. In Java,abstraction is achieved
using abstract classes and interfaces. ...
EXAMPLE OF ABSTRACTION
Example :
// concept of Abstraction
abstract class Shape
{
String color;
// these are abstract methods
abstract double area();
public abstract String to String();
// abstract class can have constructor
public Shape(String color) {
System.out.println("Shape constructor called");
this.color = color;
}
// this is a concrete method
public String getColor() {
return color;
}
}
EXAMPLE ABSTRACT
ENCAPSULATION
Encapsulation in Java is a mechanism of
wrapping the data (variables) and code acting
on the data (methods) together as a single
unit.
Declare the variables of a class as private.
Provide public setter and getter methods to
modify and view the variables values.
EXAMPLE OF ENCAPSULATION :..
POLYMORPHISM
Polymorphism is the ability of an object to
take on many forms. The most common use
of polymorphism in OOP occurs when a
parent class reference is used to refer to a
child class object. Any Java object that can
pass more than one IS-A test is considered to
be polymorphic.
EXAMPLE OF POLYMORPHISM
HOW JAVA IS PLATFORM INDEPENDENT
 Java program, once compiled , can be run
on any platform without recompiling.
 On compilation Java program is compiled
into bytecode. This bytecode is platform
independent and can be run on any
machine. Any machine with Java Runtime
Environment can run Java Programs.
WHAT IS PACKAGE IN JAVA?
A Package is a collection of related classes. It helps organize your classes into a folder
structure and make it easy to locate and use them,
Although interfaces and classes with the same name cannot appear in the same package,
they can appear in different packages. This is possible by assigning a separate namespace
to each package.
example
Package c1;
Class c1(){
Pulblic void m1(){
System.out.println(“m1 of c1”);
}
Public static void main (String args[]);
C1 obj = new c1();
Obj.m1();
}
}
WHAT IS THE STANDARD PACKAGES
package
package is a collection of related classes and interfaces.
package is mainly used avoid naming conflicts.
package concept is similar to "namespace"
java has so many in-built packages . e.g.
java.awt
java.io
java.util
java.lang
and so on
There are many packages including the sub packages. But we can assume them in a specific
category then click the link to watch the image. java.lang, java.util, java.awt and sub categories
are shown below.
EXAMPLE OF PACKAGE AND LIBRARY
CREATION
Libraries are a great way to create modular code that can be easily shared.
In the Dart ecosystem, libraries are created and distributed as packages.
Dart has two kinds of packages: application packages, which may include
local libraries, and library packages.
WHAT MAKES A LIBRARY PACKAGE
The following diagram shows the layout of the
simplest library package:
THE MINIMAL REQUIREMENTS FOR A LIBRARY ARE:
pubspec file
The pubspec.yml file for a library is the same as for an
application package—there is no special designation to
indicate that the package is a library.
lib directory
As you might expect, the library code lives under
the lib directory and is public to other packages. You can
create any hierarchy under lib, as needed. By convention,
implementation code is placed under lib/src.
Core java

Core java

  • 1.
  • 2.
    CONTENTS  Introduction tocore java  Java features  Why java is called as platform  Difference between class and object  What is class?  Object.  Java basic primitive types  Arrays in java.  Object oriented programming  What is the Standard Packages  Example of Package and library creation  What make a library package
  • 3.
    INTRODUCTION OF JAVA Java programming language  The one we use to write our program  Compiled to byte code of JVM  Java virtual machine (JVM)  Java interpreter – interpret the compiled byte code  Software simulated CPU architecture  Cross-platform: support Linux, Windows, PalmOS…etc.  Java runtime environment (JRE)  Predefined set of java classes available to use  Core Java APIs – basic utilities, I/O, graphics, network…
  • 4.
    FEATURES OF JAVA Theprimary objective of Java programming language creation was to make it portable, simple and secure programming language. Apart from this, there are also some excellent features which play an important role in the popularity of this language. The features of Java are also known as java buzzwords.
  • 5.
    WHY JAVA ISCALLED AS “PLATFORM” A platform is basically the hardware or software environment in which a program runs. Java provides software-based platform i.e. JVM, which can run applications developed using the Java Programming Language.
  • 6.
    DIFFERENCE BETWEEN CLASSAND OBJECT class is just a blueprint. A class defines the available characteristics and behavior of a set of similar objects. e.g. Car class defined has so many attributes and behaviour such as start(),stop(),accelerate() etc, Example: Public class dog{ <<< dog this is class String breed; Int age; String color; void barking(){ } Void hungry(){ } void sleeping(){ } }
  • 7.
    WHAT IS CLASS? Class introduces a new data type  A class describes a set of objects that have identical characteristics (data elements) and behaviors (methods).  Existing classes provided by JRE  User defined classes  Once a class is established, you can make as many objects of it as you like, or none.
  • 8.
    SIMPLE EXAMPLE :CLASSPERSON  A Person has some attributes  The class defines these properties for all people  Each person gets his own copy of the fields  Attributes = properties = fields
  • 9.
    OBJECT: object or instanceis basic runtime entity. E.g. Maruti Alto, WaganR, Maruti Swift etc. Example : public class Puppy{ Public puppy(string name){ Sop(passed name is:”+name); } Public static void main(string[]args){ //this object Puppy mypuppy =new puppy(“tommy”); } }
  • 10.
    JAVA BASICS: PRIMITIVETYPES  One group of types get special treatment in Java  Variable is not created by “new”, not a reference  Variable holds the value directlyy77
  • 11.
    ARRAY INDEX  int[]age = new int[5]; The first element of array is age[], second is age[1] and so on. If the length of an array is n, the last element will be arrayName[n-1]. Since the length of arr array is 5, the last element of the array is age[4] The default initial value of elements of an array is 0 for numeric types and false for boolean.
  • 12.
    ARRAY IN LENGTH Arrayname.length  Int s =arr.length;  if we make for 5 element  if we need this statement and arraylength   in the above length show if we create array that time we don’t know size ..  And from user any number enter he is don’t know number any number entered there no fix. he is don’t know his size …for this know size that time using arraylength also use for.. loop.
  • 13.
    OBJECT ORIENTED PROGRAMMING Object-orientedprogramming (OOP) is a programming based on the concept of "objects", which are data structures that contain data, in the form of fields, often known as attributes and code in the form of procedures, often known as methods.
  • 14.
    JAVA OBJECT ORIENTED Inheritance  Abstraction  Encapsulation  Polymorphism  Interface  packages
  • 15.
    INHERITANCE inheritance is away implement IS-A relationship. Subclass inherits the super class properties like ..data member, method.inheritance is the way of resusebility of code . Example : class student { ….. Public class collagerstudent extends student{ … Show method(){ } }
  • 16.
    ABTRACTION Abstraction is aprocess of hiding the implementation details from the user. Оnly the functionality will be provided to the user. In Java,abstraction is achieved using abstract classes and interfaces. ...
  • 17.
    EXAMPLE OF ABSTRACTION Example: // concept of Abstraction abstract class Shape { String color; // these are abstract methods abstract double area(); public abstract String to String(); // abstract class can have constructor public Shape(String color) { System.out.println("Shape constructor called"); this.color = color; } // this is a concrete method public String getColor() { return color; } }
  • 18.
  • 19.
    ENCAPSULATION Encapsulation in Javais a mechanism of wrapping the data (variables) and code acting on the data (methods) together as a single unit. Declare the variables of a class as private. Provide public setter and getter methods to modify and view the variables values.
  • 20.
  • 21.
    POLYMORPHISM Polymorphism is theability of an object to take on many forms. The most common use of polymorphism in OOP occurs when a parent class reference is used to refer to a child class object. Any Java object that can pass more than one IS-A test is considered to be polymorphic.
  • 22.
  • 23.
    HOW JAVA ISPLATFORM INDEPENDENT  Java program, once compiled , can be run on any platform without recompiling.  On compilation Java program is compiled into bytecode. This bytecode is platform independent and can be run on any machine. Any machine with Java Runtime Environment can run Java Programs.
  • 24.
    WHAT IS PACKAGEIN JAVA? A Package is a collection of related classes. It helps organize your classes into a folder structure and make it easy to locate and use them, Although interfaces and classes with the same name cannot appear in the same package, they can appear in different packages. This is possible by assigning a separate namespace to each package. example Package c1; Class c1(){ Pulblic void m1(){ System.out.println(“m1 of c1”); } Public static void main (String args[]); C1 obj = new c1(); Obj.m1(); } }
  • 25.
    WHAT IS THESTANDARD PACKAGES package package is a collection of related classes and interfaces. package is mainly used avoid naming conflicts. package concept is similar to "namespace" java has so many in-built packages . e.g. java.awt java.io java.util java.lang and so on
  • 26.
    There are manypackages including the sub packages. But we can assume them in a specific category then click the link to watch the image. java.lang, java.util, java.awt and sub categories are shown below.
  • 27.
    EXAMPLE OF PACKAGEAND LIBRARY CREATION Libraries are a great way to create modular code that can be easily shared. In the Dart ecosystem, libraries are created and distributed as packages. Dart has two kinds of packages: application packages, which may include local libraries, and library packages.
  • 28.
    WHAT MAKES ALIBRARY PACKAGE The following diagram shows the layout of the simplest library package:
  • 29.
    THE MINIMAL REQUIREMENTSFOR A LIBRARY ARE: pubspec file The pubspec.yml file for a library is the same as for an application package—there is no special designation to indicate that the package is a library. lib directory As you might expect, the library code lives under the lib directory and is public to other packages. You can create any hierarchy under lib, as needed. By convention, implementation code is placed under lib/src.