SlideShare una empresa de Scribd logo
1 de 29
CORE JAVA
PRESENTRED BY:
PRIYANKA PRADHAN
ASSISTANT PROFESSOR
MJPRU,BAREILLY.
Priyanka Pradhan 1
What is Java?
• Java is a high-level programming language originally developed by Sun Microsystems and
released in 1995.
Java is:
 Object Oriented
 Platform independent:
 Simple
 Secure
 Architectural- neutral
 Portable
 Robust
 Multi-threaded
 Interpreted
 High Performance
 Distributed
 Dynamic
Priyanka Pradhan 2
Tools You Will Need
You will need the following softwares:
• Linux 7.1 or Windows xp/7/8 operating system
• Java JDK 8
• Microsoft Notepad or any other text editor
Priyanka Pradhan 3
Setting Up the Path for Windows
Assuming you have installed Java in c:Program
Filesjavajdk directory:
• Right-click on 'My Computer' and select 'Properties'.
• Click the 'Environment variables' button under the
'Advanced' tab.
• Now, alter the 'Path' variable so that it also contains
the path to the Java executable. Example, if the path is
currently set to 'C:WINDOWSSYSTEM32', then
change your path to read
'C:WINDOWSSYSTEM32;c:Program
Filesjavajdkbin'.
Priyanka Pradhan 4
Popular Java Editors
To write your Java programs, you will need a text editor.
• Notepad: On Windows machine, you can use any
simple text editor like Notepad (Recommended for this
tutorial), TextPad.
• Netbeans: A Java IDE that is open-source and free,
which can be downloaded from
http://www.netbeans.org/index.html.
• Eclipse: A Java IDE developed by the eclipse open-
source community and can be downloaded from
http://www.eclipse.org/.
Priyanka Pradhan 5
how to save the file, compile, and run
the program
• Open notepad and add the code.
• Save the file as: MyFirstJavaProgram.java.
• Open a command prompt window and go to the directory where you saved the class. Assume it's
C:.
• Type 'javac MyFirstJavaProgram.java' and press enter to compile your code. If there are no errors in
your code, the command prompt will take you to the next line (Assumption : The path variable is
set).
• Now, type ' java MyFirstJavaProgram ' to run your program.
• You will be able to see ' Hello World ' printed on the window.
C:> javac MyFirstJavaProgram.java
C:> java MyFirstJavaProgram
Hello World
Priyanka Pradhan 6
Basic Syntax
• Case Sensitivity - Java is case sensitive, which means identifier Helloand hello would have different
meaning in Java.
• Class Names - For all class names the first letter should be in Upper Case. If several words are used
to form a name of the class, each inner word's first letter should be in Upper Case.
• Example: class MyFirstJavaClass
• Method Names - All method names should start with a Lower Case letter. If several words are used
to form the name of the method, then each inner word's first letter should be in Upper Case.
Example: public void myMethodName()
• Program File Name - Name of the program file should exactly match the class name. When saving
the file, you should save it using the class name (Remember Java is case sensitive) and append
'.java' to the end of the name (if the file name and the class name do not match, your program will
not compile).
• Example: Assume 'MyFirstJavaProgram' is the class name. Then the file should be saved as
'MyFirstJavaProgram.java'
• public static void main(String args[]) - Java program processing starts from the main() method
which is a mandatory part of every Java program.
Priyanka Pradhan 7
Java Identifiers
• All Java components require names. Names used for classes,
variables, and methods are called identifiers.
• In Java, there are several points to remember about identifiers.
They are as follows:
• All identifiers should begin with a letter (A to Z or a to z), currency
character ($) or an underscore (_).
• After the first character, identifiers can have any combination of
characters.
• A key word cannot be used as an identifier.
• Most importantly, identifiers are case sensitive.
• Examples of legal identifiers: age, $salary, _value, __1_value.
• Examples of illegal identifiers: 123abc, -salary.
Priyanka Pradhan 8
Java Modifiers
It is possible to modify classes, methods, etc., by
using modifiers. There are two categories of
modifiers:
• Access Modifiers: default, public , protected,
private
• Non-access Modifiers: final, abstract, strictfp
Priyanka Pradhan 9
Java Variables
Following are the types of variables in Java:
• Local Variables
• Class Variables (Static Variables)
• Instance Variables (Non-static Variables)
Priyanka Pradhan 10
Java Arrays
• Arrays are objects that store multiple variables
of the same type. However, an array itself is
an object on the heap.
Priyanka Pradhan 11
Java Enums
• Enums were introduced in Java 5.0. Enums restrict a
variable to have one of only a few predefined values.
The values in this enumerated list are called enums.
• With the use of enums it is possible to reduce the
number of bugs in your code.
• For example, if we consider an application for a fresh
juice shop, it would be possible to restrict the glass size
to small, medium, and large. This would make sure that
it would not allow anyone to order any size other than
small, medium, or large.
Priyanka Pradhan 12
Java Keywords
These reserved words may not be used as constant
or variable or any other identifier names.
• abstract
• assert
• boolean
• break
• byte
• case
• catch
• char
Priyanka Pradhan 13
Comments in Java
• Java supports single-line and multi-line comments very similar to C
and C++. All characters available inside any comment are ignored by
Java compiler.
public class MyFirstJavaProgram{
/* This is my first java program.
* This is an example of multi-line comments.
*/
public static void main(String []args){
// This is an example of single line comment
System.out.println("Hello World");
}
}
Priyanka Pradhan 14
Inheritance
• In Java, classes can be derived from classes.
Basically, if you need to create a new class and
here is already a class that has some of the code
you require, then it is possible to derive your new
class from the already existing code.
• This concept allows you to reuse the fields and
methods of the existing class without having to
rewrite the code in a new class. In this scenario,
the existing class is called the superclass and the
derived class is called the subclass.
Priyanka Pradhan 15
Interfaces
• In Java language, an interface can be defined
as a contract between objects on how to
communicate with each other. Interfaces play
a vital role when it comes to the concept of
inheritance.
• An interface defines the methods, a deriving
class (subclass) should use. But the
implementation of the methods is totally up
to the subclass.
Priyanka Pradhan 16
Java – Objects & Classes
Java is an Object-Oriented Language. As a language that has
the Object-Oriented feature, Java supports the following
fundamental concepts:
• Polymorphism
• Inheritance
• Encapsulation
• Abstraction
• Classes
• Objects
• Instance
• Method
• Message Parsing
Priyanka Pradhan 17
Contd…
• Object - Objects have states and behaviors.
Example: A dog has states - color, name, breed as
well as behaviors – wagging the tail, barking,
eating. An object is an instance of a class.
• Class - A class can be defined as a
template/blueprint that describes the
behavior/state that the object of its type support.
Priyanka Pradhan 18
Objects in Java
• If we consider the real-world, we can find many
objects around us, cars, dogs, humans, etc. All
these objects have a state and a behavior.
• Software objects also have a state and a behavior.
A software object's state is stored in fields and
behavior is shown via methods.
• in software development, methods operate on
the internal state of an object and the object-to-
object communication is done via methods.
Priyanka Pradhan 19
Classes in Java
• A class is a blueprint from which individual objects are created.
public class Dog{
String breed;
int ageC;
String color;
void barking(){
}
void hungry(){
}
void sleeping(){
}
}
Priyanka Pradhan 20
Contd…
A class can contain any of the following variable types.
• Local variables: Variables defined inside methods,
constructors or blocks are called local variables. The
variable will be declared and initialized within the method
and the variable will be destroyed when the method has
completed.
• Instance variables: Instance variables are variables within a
class but outside any method. These variables are initialized
when the class is instantiated. Instance variables can be
accessed from inside any method, constructor or blocks of
that particular class.
• Class variables: Class variables are variables declared
within a class, outside any method, with the static keyword.
Priyanka Pradhan 21
Constructors
• Every class has a constructor.
• If we do not explicitly write a constructor for a class, the Java compiler
builds a default constructor for that class.
• Each time a new object is created, at least one constructor will be invoked.
The main rule of constructors is that they should have the same name as
the class. A class can have more than one constructor.
example of a constructor:
public class Puppy{
public Puppy(){
}
public Puppy(String name){
// This constructor has one parameter, name.
}
}
Priyanka Pradhan 22
Creating an Object
• In Java, the new keyword is used to create new
objects.
There are three steps when creating an object from
a class:
• Declaration: A variable declaration with a
variable name with an object type.
• Instantiation: The 'new' keyword is used to
create the object.
• Initialization: The 'new' keyword is followed by a
call to a constructor. This call initializes the new
object.
Priyanka Pradhan 23
Contd…
example of creating an object:
public class Puppy{
public Puppy(String name){
// This constructor has one parameter, name.
System.out.println("Passed Name is :" + name );
}
public static void main(String []args){
// Following statement would create an object myPuppy
Puppy myPuppy = new Puppy( "tommy" );
}
}
If we compile and run the above program, then it will produce the following result:
Passed Name is :tommy
Priyanka Pradhan 24
Accessing Instance Variables and
Methods
Instance variables and methods are accessed via created
objects.
/* First create an object */
ObjectReference = new Constructor();
/* Now call a variable as follows */
ObjectReference.variableName;
/* Now you can call a class method as follows */
ObjectReference.MethodName();
Priyanka Pradhan 25
how to access instance variables and
methods of a class
public class Puppy{
int puppyAge;
public Puppy(String name){
System.out.println("Name chosen is :" + name );
}
public void setAge( int age ){
puppyAge = age;
}
public int getAge( ){
System.out.println("Puppy's age is :" + puppyAge );
return puppyAge;
}
public static void main(String []args){
Puppy myPuppy = new Puppy( "tommy" );
myPuppy.setAge( 2 );
myPuppy.getAge( );
System.out.println("Variable Value :" + myPuppy.puppyAge );
}
Priyanka Pradhan 26
Java Package
• it is a way of categorizing the classes and
interfaces. When developing applications in
Java, hundreds of classes and interfaces will
be written, therefore categorizing these
classes is a must as well as makes life much
easier.
Priyanka Pradhan 27
Import Statements
• In Java if a fully qualified name, which includes
the package and the class name is given, then the
compiler can easily locate the source code or
classes. Import statement is a way of giving the
proper location for the compiler to find that
particular class.
• For example, the following line would ask the
compiler to load all the classes available in
directory java_installation/java/io:
• import java.io.*;
Priyanka Pradhan 28
Java – Basic Datatypes
There are two data types available in Java:
• Primitive Datatypes
• Reference/Object Datatypes
Priyanka Pradhan 29

Más contenido relacionado

La actualidad más candente

Introduction to java
Introduction to java Introduction to java
Introduction to java Java Lover
 
Basic Java Programming
Basic Java ProgrammingBasic Java Programming
Basic Java ProgrammingMath-Circle
 
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...Edureka!
 
Java Presentation For Syntax
Java Presentation For SyntaxJava Presentation For Syntax
Java Presentation For SyntaxPravinYalameli
 
Introduction to java (revised)
Introduction to java (revised)Introduction to java (revised)
Introduction to java (revised)Sujit Majety
 
Elements of Java Language
Elements of Java Language Elements of Java Language
Elements of Java Language Hitesh-Java
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to javaAjay Sharma
 
JRE , JDK and platform independent nature of JAVA
JRE , JDK and platform independent nature of JAVAJRE , JDK and platform independent nature of JAVA
JRE , JDK and platform independent nature of JAVAMehak Tawakley
 
Introduction to java
Introduction to java Introduction to java
Introduction to java Sandeep Rawat
 
Features of JAVA Programming Language.
Features of JAVA Programming Language.Features of JAVA Programming Language.
Features of JAVA Programming Language.Bhautik Jethva
 
Java Presentation
Java PresentationJava Presentation
Java Presentationpm2214
 
Java Programming | Java Tutorial For Beginners | Java Training | Edureka
Java Programming | Java Tutorial For Beginners | Java Training | EdurekaJava Programming | Java Tutorial For Beginners | Java Training | Edureka
Java Programming | Java Tutorial For Beginners | Java Training | EdurekaEdureka!
 
Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java ProgrammingRavi Kant Sahu
 

La actualidad más candente (20)

Introduction to java
Introduction to java Introduction to java
Introduction to java
 
Core java slides
Core java slidesCore java slides
Core java slides
 
Basic Java Programming
Basic Java ProgrammingBasic Java Programming
Basic Java Programming
 
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
 
Java History
Java HistoryJava History
Java History
 
Basic of Java
Basic of JavaBasic of Java
Basic of Java
 
Java Presentation For Syntax
Java Presentation For SyntaxJava Presentation For Syntax
Java Presentation For Syntax
 
Introduction of java
Introduction  of javaIntroduction  of java
Introduction of java
 
Introduction to java (revised)
Introduction to java (revised)Introduction to java (revised)
Introduction to java (revised)
 
Elements of Java Language
Elements of Java Language Elements of Java Language
Elements of Java Language
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
JRE , JDK and platform independent nature of JAVA
JRE , JDK and platform independent nature of JAVAJRE , JDK and platform independent nature of JAVA
JRE , JDK and platform independent nature of JAVA
 
Introduction to java
Introduction to java Introduction to java
Introduction to java
 
Java Introduction
Java IntroductionJava Introduction
Java Introduction
 
Features of JAVA Programming Language.
Features of JAVA Programming Language.Features of JAVA Programming Language.
Features of JAVA Programming Language.
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
 
Java Presentation
Java PresentationJava Presentation
Java Presentation
 
Java Programming | Java Tutorial For Beginners | Java Training | Edureka
Java Programming | Java Tutorial For Beginners | Java Training | EdurekaJava Programming | Java Tutorial For Beginners | Java Training | Edureka
Java Programming | Java Tutorial For Beginners | Java Training | Edureka
 
Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java Programming
 
Arrays in Java
Arrays in Java Arrays in Java
Arrays in Java
 

Similar a Core Java

cs213Lecture_1 java programming oopsss.pptx
cs213Lecture_1 java programming oopsss.pptxcs213Lecture_1 java programming oopsss.pptx
cs213Lecture_1 java programming oopsss.pptxmshanajoel6
 
Top 100 Java Interview Questions with Detailed Answers
Top 100 Java Interview Questions with Detailed AnswersTop 100 Java Interview Questions with Detailed Answers
Top 100 Java Interview Questions with Detailed AnswersWhizlabs
 
Java Basics for selenium
Java Basics for seleniumJava Basics for selenium
Java Basics for seleniumapoorvams
 
Basic online java course - Brainsmartlabs
Basic online java course  - BrainsmartlabsBasic online java course  - Brainsmartlabs
Basic online java course - Brainsmartlabsbrainsmartlabsedu
 
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...Ayes Chinmay
 
Complete PPT about the Java lokesh kept it
Complete PPT about the Java lokesh kept itComplete PPT about the Java lokesh kept it
Complete PPT about the Java lokesh kept itlokeshpappaka10
 
Classes in Java great learning.pdf
Classes in Java great learning.pdfClasses in Java great learning.pdf
Classes in Java great learning.pdfSHASHIKANT346021
 
OCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference CardOCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference CardHari kiran G
 
Dev labs alliance top 20 basic java interview questions for sdet
Dev labs alliance top 20 basic java interview questions for sdetDev labs alliance top 20 basic java interview questions for sdet
Dev labs alliance top 20 basic java interview questions for sdetDevLabs Alliance
 
Top 20 basic java interview questions for SDET
Top 20 basic java interview questions for SDETTop 20 basic java interview questions for SDET
Top 20 basic java interview questions for SDETDevLabs Alliance
 

Similar a Core Java (20)

cs213Lecture_1 java programming oopsss.pptx
cs213Lecture_1 java programming oopsss.pptxcs213Lecture_1 java programming oopsss.pptx
cs213Lecture_1 java programming oopsss.pptx
 
Top 100 Java Interview Questions with Detailed Answers
Top 100 Java Interview Questions with Detailed AnswersTop 100 Java Interview Questions with Detailed Answers
Top 100 Java Interview Questions with Detailed Answers
 
Java
JavaJava
Java
 
Java_notes.ppt
Java_notes.pptJava_notes.ppt
Java_notes.ppt
 
oop unit1.pptx
oop unit1.pptxoop unit1.pptx
oop unit1.pptx
 
Basic syntax
Basic syntaxBasic syntax
Basic syntax
 
Viva file
Viva fileViva file
Viva file
 
CS8392 OOP
CS8392 OOPCS8392 OOP
CS8392 OOP
 
Java Basics for selenium
Java Basics for seleniumJava Basics for selenium
Java Basics for selenium
 
Basic online java course - Brainsmartlabs
Basic online java course  - BrainsmartlabsBasic online java course  - Brainsmartlabs
Basic online java course - Brainsmartlabs
 
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...
 
Complete PPT about the Java lokesh kept it
Complete PPT about the Java lokesh kept itComplete PPT about the Java lokesh kept it
Complete PPT about the Java lokesh kept it
 
JAVA PPT -3 BY ADI.pdf
JAVA PPT -3 BY ADI.pdfJAVA PPT -3 BY ADI.pdf
JAVA PPT -3 BY ADI.pdf
 
Java Programming Fundamentals
Java Programming Fundamentals Java Programming Fundamentals
Java Programming Fundamentals
 
JAVA PPT -2 BY ADI.pdf
JAVA PPT -2 BY ADI.pdfJAVA PPT -2 BY ADI.pdf
JAVA PPT -2 BY ADI.pdf
 
Classes in Java great learning.pdf
Classes in Java great learning.pdfClasses in Java great learning.pdf
Classes in Java great learning.pdf
 
OCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference CardOCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference Card
 
Dev labs alliance top 20 basic java interview questions for sdet
Dev labs alliance top 20 basic java interview questions for sdetDev labs alliance top 20 basic java interview questions for sdet
Dev labs alliance top 20 basic java interview questions for sdet
 
inheritance.pptx
inheritance.pptxinheritance.pptx
inheritance.pptx
 
Top 20 basic java interview questions for SDET
Top 20 basic java interview questions for SDETTop 20 basic java interview questions for SDET
Top 20 basic java interview questions for SDET
 

Más de Priyanka Pradhan

Tomato disease detection using deep learning convolutional neural network
Tomato disease detection using deep learning convolutional neural networkTomato disease detection using deep learning convolutional neural network
Tomato disease detection using deep learning convolutional neural networkPriyanka Pradhan
 
programming with python ppt
programming with python pptprogramming with python ppt
programming with python pptPriyanka Pradhan
 
Image Processing Based Signature Recognition and Verification Technique Using...
Image Processing Based Signature Recognition and Verification Technique Using...Image Processing Based Signature Recognition and Verification Technique Using...
Image Processing Based Signature Recognition and Verification Technique Using...Priyanka Pradhan
 
GrayBox Testing and Crud Testing By: Er. Priyanka Pradhan
GrayBox Testing and Crud Testing By: Er. Priyanka PradhanGrayBox Testing and Crud Testing By: Er. Priyanka Pradhan
GrayBox Testing and Crud Testing By: Er. Priyanka PradhanPriyanka Pradhan
 
The agile requirements refinery(SRUM) by: Priyanka Pradhan
The agile requirements refinery(SRUM) by: Priyanka PradhanThe agile requirements refinery(SRUM) by: Priyanka Pradhan
The agile requirements refinery(SRUM) by: Priyanka PradhanPriyanka Pradhan
 
Social tagging and its trend
Social tagging and its trendSocial tagging and its trend
Social tagging and its trendPriyanka Pradhan
 
Behavioral pattern By:-Priyanka Pradhan
Behavioral pattern By:-Priyanka PradhanBehavioral pattern By:-Priyanka Pradhan
Behavioral pattern By:-Priyanka PradhanPriyanka Pradhan
 
software product and its characteristics
software product and its characteristicssoftware product and its characteristics
software product and its characteristicsPriyanka Pradhan
 
EDI(ELECTRONIC DATA INTERCHANGE)
EDI(ELECTRONIC DATA INTERCHANGE)EDI(ELECTRONIC DATA INTERCHANGE)
EDI(ELECTRONIC DATA INTERCHANGE)Priyanka Pradhan
 
collaborative tagging :-by Er. Priyanka Pradhan
collaborative tagging :-by Er. Priyanka Pradhancollaborative tagging :-by Er. Priyanka Pradhan
collaborative tagging :-by Er. Priyanka PradhanPriyanka Pradhan
 
Deploying java beans in jsp
Deploying java beans in jspDeploying java beans in jsp
Deploying java beans in jspPriyanka Pradhan
 
SOFTWARE PROCESS MONITORING AND AUDIT
SOFTWARE PROCESS MONITORING AND AUDITSOFTWARE PROCESS MONITORING AND AUDIT
SOFTWARE PROCESS MONITORING AND AUDITPriyanka Pradhan
 
s/w metrics monitoring and control
s/w metrics monitoring and controls/w metrics monitoring and control
s/w metrics monitoring and controlPriyanka Pradhan
 

Más de Priyanka Pradhan (19)

Tomato disease detection using deep learning convolutional neural network
Tomato disease detection using deep learning convolutional neural networkTomato disease detection using deep learning convolutional neural network
Tomato disease detection using deep learning convolutional neural network
 
Applet
AppletApplet
Applet
 
Servlet
ServletServlet
Servlet
 
Css
CssCss
Css
 
Javascript
JavascriptJavascript
Javascript
 
XML
XMLXML
XML
 
programming with python ppt
programming with python pptprogramming with python ppt
programming with python ppt
 
Image Processing Based Signature Recognition and Verification Technique Using...
Image Processing Based Signature Recognition and Verification Technique Using...Image Processing Based Signature Recognition and Verification Technique Using...
Image Processing Based Signature Recognition and Verification Technique Using...
 
GrayBox Testing and Crud Testing By: Er. Priyanka Pradhan
GrayBox Testing and Crud Testing By: Er. Priyanka PradhanGrayBox Testing and Crud Testing By: Er. Priyanka Pradhan
GrayBox Testing and Crud Testing By: Er. Priyanka Pradhan
 
The agile requirements refinery(SRUM) by: Priyanka Pradhan
The agile requirements refinery(SRUM) by: Priyanka PradhanThe agile requirements refinery(SRUM) by: Priyanka Pradhan
The agile requirements refinery(SRUM) by: Priyanka Pradhan
 
Social tagging and its trend
Social tagging and its trendSocial tagging and its trend
Social tagging and its trend
 
Behavioral pattern By:-Priyanka Pradhan
Behavioral pattern By:-Priyanka PradhanBehavioral pattern By:-Priyanka Pradhan
Behavioral pattern By:-Priyanka Pradhan
 
software product and its characteristics
software product and its characteristicssoftware product and its characteristics
software product and its characteristics
 
EDI(ELECTRONIC DATA INTERCHANGE)
EDI(ELECTRONIC DATA INTERCHANGE)EDI(ELECTRONIC DATA INTERCHANGE)
EDI(ELECTRONIC DATA INTERCHANGE)
 
collaborative tagging :-by Er. Priyanka Pradhan
collaborative tagging :-by Er. Priyanka Pradhancollaborative tagging :-by Er. Priyanka Pradhan
collaborative tagging :-by Er. Priyanka Pradhan
 
Deploying java beans in jsp
Deploying java beans in jspDeploying java beans in jsp
Deploying java beans in jsp
 
SOFTWARE PROCESS MONITORING AND AUDIT
SOFTWARE PROCESS MONITORING AND AUDITSOFTWARE PROCESS MONITORING AND AUDIT
SOFTWARE PROCESS MONITORING AND AUDIT
 
Pcmm
PcmmPcmm
Pcmm
 
s/w metrics monitoring and control
s/w metrics monitoring and controls/w metrics monitoring and control
s/w metrics monitoring and control
 

Último

Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 

Último (20)

Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 

Core Java

  • 1. CORE JAVA PRESENTRED BY: PRIYANKA PRADHAN ASSISTANT PROFESSOR MJPRU,BAREILLY. Priyanka Pradhan 1
  • 2. What is Java? • Java is a high-level programming language originally developed by Sun Microsystems and released in 1995. Java is:  Object Oriented  Platform independent:  Simple  Secure  Architectural- neutral  Portable  Robust  Multi-threaded  Interpreted  High Performance  Distributed  Dynamic Priyanka Pradhan 2
  • 3. Tools You Will Need You will need the following softwares: • Linux 7.1 or Windows xp/7/8 operating system • Java JDK 8 • Microsoft Notepad or any other text editor Priyanka Pradhan 3
  • 4. Setting Up the Path for Windows Assuming you have installed Java in c:Program Filesjavajdk directory: • Right-click on 'My Computer' and select 'Properties'. • Click the 'Environment variables' button under the 'Advanced' tab. • Now, alter the 'Path' variable so that it also contains the path to the Java executable. Example, if the path is currently set to 'C:WINDOWSSYSTEM32', then change your path to read 'C:WINDOWSSYSTEM32;c:Program Filesjavajdkbin'. Priyanka Pradhan 4
  • 5. Popular Java Editors To write your Java programs, you will need a text editor. • Notepad: On Windows machine, you can use any simple text editor like Notepad (Recommended for this tutorial), TextPad. • Netbeans: A Java IDE that is open-source and free, which can be downloaded from http://www.netbeans.org/index.html. • Eclipse: A Java IDE developed by the eclipse open- source community and can be downloaded from http://www.eclipse.org/. Priyanka Pradhan 5
  • 6. how to save the file, compile, and run the program • Open notepad and add the code. • Save the file as: MyFirstJavaProgram.java. • Open a command prompt window and go to the directory where you saved the class. Assume it's C:. • Type 'javac MyFirstJavaProgram.java' and press enter to compile your code. If there are no errors in your code, the command prompt will take you to the next line (Assumption : The path variable is set). • Now, type ' java MyFirstJavaProgram ' to run your program. • You will be able to see ' Hello World ' printed on the window. C:> javac MyFirstJavaProgram.java C:> java MyFirstJavaProgram Hello World Priyanka Pradhan 6
  • 7. Basic Syntax • Case Sensitivity - Java is case sensitive, which means identifier Helloand hello would have different meaning in Java. • Class Names - For all class names the first letter should be in Upper Case. If several words are used to form a name of the class, each inner word's first letter should be in Upper Case. • Example: class MyFirstJavaClass • Method Names - All method names should start with a Lower Case letter. If several words are used to form the name of the method, then each inner word's first letter should be in Upper Case. Example: public void myMethodName() • Program File Name - Name of the program file should exactly match the class name. When saving the file, you should save it using the class name (Remember Java is case sensitive) and append '.java' to the end of the name (if the file name and the class name do not match, your program will not compile). • Example: Assume 'MyFirstJavaProgram' is the class name. Then the file should be saved as 'MyFirstJavaProgram.java' • public static void main(String args[]) - Java program processing starts from the main() method which is a mandatory part of every Java program. Priyanka Pradhan 7
  • 8. Java Identifiers • All Java components require names. Names used for classes, variables, and methods are called identifiers. • In Java, there are several points to remember about identifiers. They are as follows: • All identifiers should begin with a letter (A to Z or a to z), currency character ($) or an underscore (_). • After the first character, identifiers can have any combination of characters. • A key word cannot be used as an identifier. • Most importantly, identifiers are case sensitive. • Examples of legal identifiers: age, $salary, _value, __1_value. • Examples of illegal identifiers: 123abc, -salary. Priyanka Pradhan 8
  • 9. Java Modifiers It is possible to modify classes, methods, etc., by using modifiers. There are two categories of modifiers: • Access Modifiers: default, public , protected, private • Non-access Modifiers: final, abstract, strictfp Priyanka Pradhan 9
  • 10. Java Variables Following are the types of variables in Java: • Local Variables • Class Variables (Static Variables) • Instance Variables (Non-static Variables) Priyanka Pradhan 10
  • 11. Java Arrays • Arrays are objects that store multiple variables of the same type. However, an array itself is an object on the heap. Priyanka Pradhan 11
  • 12. Java Enums • Enums were introduced in Java 5.0. Enums restrict a variable to have one of only a few predefined values. The values in this enumerated list are called enums. • With the use of enums it is possible to reduce the number of bugs in your code. • For example, if we consider an application for a fresh juice shop, it would be possible to restrict the glass size to small, medium, and large. This would make sure that it would not allow anyone to order any size other than small, medium, or large. Priyanka Pradhan 12
  • 13. Java Keywords These reserved words may not be used as constant or variable or any other identifier names. • abstract • assert • boolean • break • byte • case • catch • char Priyanka Pradhan 13
  • 14. Comments in Java • Java supports single-line and multi-line comments very similar to C and C++. All characters available inside any comment are ignored by Java compiler. public class MyFirstJavaProgram{ /* This is my first java program. * This is an example of multi-line comments. */ public static void main(String []args){ // This is an example of single line comment System.out.println("Hello World"); } } Priyanka Pradhan 14
  • 15. Inheritance • In Java, classes can be derived from classes. Basically, if you need to create a new class and here is already a class that has some of the code you require, then it is possible to derive your new class from the already existing code. • This concept allows you to reuse the fields and methods of the existing class without having to rewrite the code in a new class. In this scenario, the existing class is called the superclass and the derived class is called the subclass. Priyanka Pradhan 15
  • 16. Interfaces • In Java language, an interface can be defined as a contract between objects on how to communicate with each other. Interfaces play a vital role when it comes to the concept of inheritance. • An interface defines the methods, a deriving class (subclass) should use. But the implementation of the methods is totally up to the subclass. Priyanka Pradhan 16
  • 17. Java – Objects & Classes Java is an Object-Oriented Language. As a language that has the Object-Oriented feature, Java supports the following fundamental concepts: • Polymorphism • Inheritance • Encapsulation • Abstraction • Classes • Objects • Instance • Method • Message Parsing Priyanka Pradhan 17
  • 18. Contd… • Object - Objects have states and behaviors. Example: A dog has states - color, name, breed as well as behaviors – wagging the tail, barking, eating. An object is an instance of a class. • Class - A class can be defined as a template/blueprint that describes the behavior/state that the object of its type support. Priyanka Pradhan 18
  • 19. Objects in Java • If we consider the real-world, we can find many objects around us, cars, dogs, humans, etc. All these objects have a state and a behavior. • Software objects also have a state and a behavior. A software object's state is stored in fields and behavior is shown via methods. • in software development, methods operate on the internal state of an object and the object-to- object communication is done via methods. Priyanka Pradhan 19
  • 20. Classes in Java • A class is a blueprint from which individual objects are created. public class Dog{ String breed; int ageC; String color; void barking(){ } void hungry(){ } void sleeping(){ } } Priyanka Pradhan 20
  • 21. Contd… A class can contain any of the following variable types. • Local variables: Variables defined inside methods, constructors or blocks are called local variables. The variable will be declared and initialized within the method and the variable will be destroyed when the method has completed. • Instance variables: Instance variables are variables within a class but outside any method. These variables are initialized when the class is instantiated. Instance variables can be accessed from inside any method, constructor or blocks of that particular class. • Class variables: Class variables are variables declared within a class, outside any method, with the static keyword. Priyanka Pradhan 21
  • 22. Constructors • Every class has a constructor. • If we do not explicitly write a constructor for a class, the Java compiler builds a default constructor for that class. • Each time a new object is created, at least one constructor will be invoked. The main rule of constructors is that they should have the same name as the class. A class can have more than one constructor. example of a constructor: public class Puppy{ public Puppy(){ } public Puppy(String name){ // This constructor has one parameter, name. } } Priyanka Pradhan 22
  • 23. Creating an Object • In Java, the new keyword is used to create new objects. There are three steps when creating an object from a class: • Declaration: A variable declaration with a variable name with an object type. • Instantiation: The 'new' keyword is used to create the object. • Initialization: The 'new' keyword is followed by a call to a constructor. This call initializes the new object. Priyanka Pradhan 23
  • 24. Contd… example of creating an object: public class Puppy{ public Puppy(String name){ // This constructor has one parameter, name. System.out.println("Passed Name is :" + name ); } public static void main(String []args){ // Following statement would create an object myPuppy Puppy myPuppy = new Puppy( "tommy" ); } } If we compile and run the above program, then it will produce the following result: Passed Name is :tommy Priyanka Pradhan 24
  • 25. Accessing Instance Variables and Methods Instance variables and methods are accessed via created objects. /* First create an object */ ObjectReference = new Constructor(); /* Now call a variable as follows */ ObjectReference.variableName; /* Now you can call a class method as follows */ ObjectReference.MethodName(); Priyanka Pradhan 25
  • 26. how to access instance variables and methods of a class public class Puppy{ int puppyAge; public Puppy(String name){ System.out.println("Name chosen is :" + name ); } public void setAge( int age ){ puppyAge = age; } public int getAge( ){ System.out.println("Puppy's age is :" + puppyAge ); return puppyAge; } public static void main(String []args){ Puppy myPuppy = new Puppy( "tommy" ); myPuppy.setAge( 2 ); myPuppy.getAge( ); System.out.println("Variable Value :" + myPuppy.puppyAge ); } Priyanka Pradhan 26
  • 27. Java Package • it is a way of categorizing the classes and interfaces. When developing applications in Java, hundreds of classes and interfaces will be written, therefore categorizing these classes is a must as well as makes life much easier. Priyanka Pradhan 27
  • 28. Import Statements • In Java if a fully qualified name, which includes the package and the class name is given, then the compiler can easily locate the source code or classes. Import statement is a way of giving the proper location for the compiler to find that particular class. • For example, the following line would ask the compiler to load all the classes available in directory java_installation/java/io: • import java.io.*; Priyanka Pradhan 28
  • 29. Java – Basic Datatypes There are two data types available in Java: • Primitive Datatypes • Reference/Object Datatypes Priyanka Pradhan 29

Notas del editor

  1. Note: Enums can be declared as their own or inside a class. Methods, variables, constructors can be defined inside enums as well.
  2. If we compile and run the above program, then it will produce the following result: Name chosen is :tommy Puppy's age is :2 Variable Value :2