SlideShare a Scribd company logo
Quality Assurance /
Software Testing Training
Core Java for Selenium
Page 2Classification: Restricted
Agenda
• Java Fundamentals
• Introduction to Java
• Programming Language fundamentals
• Key Java Concepts
• Strings and collections
Page 3Classification: Restricted
1. Java Fundamentals
i. History of Java
ii. Features of java
iii. Introduction to OOPs
Page 4Classification: Restricted
i. History of Java
• Background: Electronic Consumer Device
• Sun Commissioned ‘Project Green’
• Developed language ‘Oak-Later renamed to Java’
• Invented by Dr.James A.Gosling and his team in 1994
• Was dismissed as just another OO programming language
• Became popular with the rising popularity of ‘www’
Page 5Classification: Restricted
ii. Features of Java
• Simple
• Robust
• Distributed
• Secure
• Portable
• Interpreted
• Multithreaded
• Portable
• Object Oriented
Page 6Classification: Restricted
Simple
• Java designed as closely to C++ as possible
• Omits many confusing and rarely used features :
No header files
Structures
Unions
Pointers
Operator overloading
Virtual base class etc..
Page 7Classification: Restricted
Robust
• Java Programs are reliable
• Early checking for potential problems
• Dynamic checking to eliminate error-prone situations.
• Developer doesn’t have to worry about
Bad Pointers
Memory Allocation Errors
Memory Leakage
Page 8Classification: Restricted
Distributed
• An application when divided into smaller units is called as distributed
system
• Extensive library support protocols like TCP/IP, HTTP & FTP
• Applications can access objects across the net with ease.
Creating socket connections
Servlets
CGI Scripting
RMI enables communication between different objects
Page 9Classification: Restricted
Platform Independence
.java file Intermediate
language code
abc.java abc.class
• Java compiler generates byte code
Platform independent
Bytecode code is an architecture-neutral file format to transport code efficiently
independent of hardware and Operating systems
The use of the same bytecode for all JVMs on all platforms
Allows Java to be described as a “compile once, run everywhere”
programming language
Source
Code
Compile
Byte
Code
Window
Linux
Mac
Page 10Classification: Restricted
Secure
• Java applications used in distributed environments require emphasis on
memory
Security Manager
Allows applications to implement a security policy before
performing a possible unsafe or sensitive operation.
ByteCode Verifier
ByteCode Verifier is responsible for verifying the byte codes.
ByteCode do not violate Java’s security restrictions.
Page 11Classification: Restricted
Portable
• Behavior of java basic types & arithmetic operators is consistent
• Java programs’s behavior is same on every platform – no data type
incompatibilities across platforms.
 int is always a 32-bit int
Strings stored in standard Unicode format
Page 12Classification: Restricted
Interpreted
• ByteCode can be executed on any machine that has java interpreter and
java run time system
• Classes are linked only on need basis
• Java is both compiled and interpreted
Page 13Classification: Restricted
iii) Object Oriented Approach
• Key concepts of object oriented programming are
• Abstraction
• Encapsulation
• Inheritance
• Polymorphism
Page 14Classification: Restricted
Abstraction
• Abstraction is the process of identifying the key aspects of an entity and
ignoring the rest
• Only those aspects are selected that are important to the current problem
scenario
• Eg) Abstraction of a person object
• Enumerate attributes of a “person object” that needs to be created for
developing a database
• Useful for social survey
• Useful for health care industry
• Useful for payroll system
Page 15Classification: Restricted
Abstraction of a Person Object
Social Survey Health Care Payroll System
Name Name Name
Age Age Age
Marital status -- --
Religion -- --
Income group -- --
Address Address Address
Occupation occupation Occupation
-- Blood group --
-- Weight --
-- Previous record --
-- -- Basic salary
-- -- Department
-- -- Qualification
Page 16Classification: Restricted
Abstraction :Process of identifying the key aspects of an entity & ignoring the
rest
Encapsulation: Ensures that data within an object is protected and accessed
only by its methods
Page 17Classification: Restricted
Encapsulation
• Encapsulation is a mechanism used to hide the data, internal structure and
implementation details of an object
• All interaction with the object is through the public interface of operations
• The user knows only about the interface, any changes to the
implementation does not affect the user
Methods
Variables
Page 18Classification: Restricted
What is an Object?
• An entity is an entity which has a well defined structure and behaviour.
An object possesses certain characteristics as:
• State
• Behavior
• Identity
Page 19Classification: Restricted
State of an Object
• The state of an object includes the current values of all its attributes.
• An attribute can be static or dynamic
• Employee Attributes
empid
name static
gender
Age
Address
Phone
Basicsal dynamic
Education
experience
Page 20Classification: Restricted
Behavior of the Object
• Behavior is how an object acts and reacts, in terms of its changes and
message passing
Employee as an object
calculateSalary
printDetails Employee
Totality of operations – how an employee behaves or
responds to, is the behavior of the person.
Page 21Classification: Restricted
Identity of an Object
• Identity is that property of an object which distinguishes it from all other
objects
• A single or a group of attributes can be an identity of an object
Employee
empId
Name
Gender
Phone
Age
Address
Phone
Basicsal
Education
empId uniquely
identifies a person
among others
Page 22Classification: Restricted
Person as an Object
Attributes State Identity Behavior
empID empId = 10 empId = 10 Swipe Card
Name Name =
“Dhruv”
Fill TimeSheet
Gender Gender =
“male”
Wear Icard
Age Age=27 Calculate
Salary
Address Address =
“pune”
Print details
Phone Phone =
2342432
basicSalary basicSalary=80
00
Education
experience
Page 23Classification: Restricted
Inheritance
• Classification helps in handling complexity
• Inheritance is the process by which one object acquire the properties of
another object
• “is a ”kind of hierarchy
Person
Employee
Wage
Employee Manager
Sales Person
Page 24Classification: Restricted
Inheritance
• Generalization
Factoring out common elements within a set of categories into a more
general category called super class.
Requires good skill of abstraction
• Specialization
Allows to capture specific features of a set of objects.
Requires a depth of knowledge of domain.
Page 25Classification: Restricted
Polymorphism
• The ability of different types of related objects to respond to the same
message in their own ways is called polymorphism
• Polymorphism helps to design extensible software, as new objects can be
added to the design without rewriting existing procedures
Page 26Classification: Restricted
Polymorphism: same method having different implementations
• Compile/ static polymorphism – by function overloading
• Run time polymorphism – by function overriding
Page 27Classification: Restricted
2. Introduction to Java
i. Compilation & execution of Java Program
ii. JDK, JVM & JRE
iii. Class & Object
iv. Access Modifiers
v. Data type
vi. Java class syntax
Page 28Classification: Restricted
i) Compilation & Execution of Java Program
.java file
Java Class libraries
JDK
JRE
Source
code
compiler Byte
code
Class
loader
ByteCode verifier
Interpreter
Native OS
JVM
awt net rmii/o
Page 29Classification: Restricted
ii) JDK, JVM and JRE
• JDK (Java Development Kit)
Comes along with standard class libraries and JVM embedded in it.
Contains software development tools such as a compiler or a debugger
which are used to compile and run the Java program.
• JRE(Java Runtime Environment)
It is an implementation of JVM, which actually executes the Java program
JRE provides some standard libraries and the JVM which can be used to
execute the java program
• JVM(Java Virtual Machine)
• JVM loads the appropriate class files for execution the java program and
then execute it
• JVM is a :
- Abstract specification
- A concrete implementation or
- A runtime instance
Page 30Classification: Restricted
iii) Anatomy of JAVA class
• The term ‘class’ comes from the word called ‘classification’
• A class is a template for creation of like objects
• An object is an instance of class
• Classes are used to map real world entities into data members and member
functions
• By writing a class and creating objects of the class one can map two key
concepts of major pillars of object msodel i.e. Abstraction and
Encapsulation
Page 31Classification: Restricted
Class: A class is a template for the creation of like objects
Page 32Classification: Restricted
Page 33Classification: Restricted
iv) Access Modifiers
• Access modifiers allow to specify the scope of the class members. We use
access modifiers to define the access control for classes, methods and
variables
• Access modifiers are of 4 types:
private – is accessible only within class
default – if we don’t specify any modifier then it is treated as default, this
can be accessible only within package
protected – is accessible within package , outside of the package but
through inheritance only
public – is accessible anywhere
• Non Access Modifiers
Static
Final : more like constant in C
Page 34Classification: Restricted
Modifier Within
Class
Within
Package
Outside of
Package
(By Sub
Class)
Outside of
Package
Private Y N N N
default Y Y N N
protected Y Y Y N
public Y Y Y Y
Page 35Classification: Restricted
v) Data Types : Is the classification of the type of data that variable can hold
in computer programming
Primitive Data Type
Boolean
Type
Numeric
Type
boolean
Integral
Type
Floating
Point Type
float double
Characte
r Type
Integer
Type
char longbyte short int
Page 36Classification: Restricted
vi) Java Class Syntax
By Convention:
class Class_Name class name starts with capital case
{ e.g. class MySample
variable_Declaration;
variable(attribute or property)
method_Declaration() { name starts with small case
….. e.g. int date
…..
}
public static void main(String args[]) Method(behavior) name starts with
{ first word small case then next
…. Words 1st letter capital case called
…. Camel case
} //end of class e.g. void printDate() {
}
Page 37Classification: Restricted
First Java Class
/* This is a comment */
//This is another comment
class MyDate
{ private int day, month, year; //variable
public void initDate() //method 1
{
day = 30;
month = 6;
year =2011;
}
public void printDate() //method 2
{
System.out.println(“Date is:” + day +”/” + month +”/” +year);
}
Page 38Classification: Restricted
Create an Object
//continuation
public static void main(String args[])
{
MyDate d = new MyDate();
//method invocation
d.initDate();
d.printDate();
}
}
Page 39Classification: Restricted
3. Language Fundamentals
i. Operators in Java
ii. Conditional & Loop statements
iii. Arrays in Java
iv. Exception handling
v. File handling
Page 40Classification: Restricted
i) Operators
• Arithmetic operators
Addition, Subtraction, Multiplication, Division, Modulus, Increment,
Decrement
• Relational operators
== , != , > , >= , < , <=
• Logical operators
Logical Not Operator !
Logical AND Operator &&
Logical OR Operator ||
• Assignment operators
=
Page 41Classification: Restricted
ii) Java Conditional & Loop statements
• Single Conditional statements
if(a>b) {
..
}
• Compound Conditional statements
If((a>b) && (a<c)) {
..
}
• Nested Conditions
if(a<b) {
if(a<c) {
if(a>b) {
}
}
}
• Java Switch statement : executes one statement from multiple conditions.
Page 42Classification: Restricted
Loop Statements
• Loop statements are used to iterate a part of the program several times.
• Three types of loops
For loop
for(initialization ; condition ;incr / decr){
//code to be executed
}
While loop
while(condition){
//code to be executed
}
Do.. While loop
do{
//code to be executed
}while(condition);
Page 43Classification: Restricted
Break, Continue & Comments
• Break statement
The Java break is used to break loop or switch statement. It breaks the
current flow of the program at specified condition. In case of inner loop, it
breaks only inner loop.
• Continue statement
The Java continue statement is used to continue loop. It continues the
current flow of the program and skips the remaining code at specified
condition. In case of inner loop, it continues only inner loop.
Comments in Java:
The java comments are statements that are not executed by the compiler
and interpreter. The comments can be used to provide information or
explanation about the variable, method, class or any statement. It can also
be used to hide program code for specific time.
Page 44Classification: Restricted
iii) Arrays in Java
Normally, array is a collection of similar type of elements that have
contiguous memory location. Java array is an object the contains elements
of similar data type
• Advantage:
Code Optimization
Random access
• Disadvantage:
Size limit
Types of Array:
• Single dimensional
• Multi dimensional
Page 45Classification: Restricted
iv. Exception Handling
• There is no perfect world
• Errors are inevitable
• Errors are shipped even with the best software
• Occur due to
Wrong input
Error on platform or system not configured
Program bugs
• Occur when the software is operational
Page 46Classification: Restricted
Types of Errors
• Logical Errors
Counter not incremented in the while loop
Wrong expression written, resulting in incorrect output
• Run time Errors
Division by Zero
Array out of bounds
Dynamic memory allocation failed
File not found
File is corrupt
Page 47Classification: Restricted
v) File Handling in Java
• High level operations/External operation
Create a folder
Delete a folder
Create a text file
Delete a text file
• Low level operations/ Internal operation
Read data from a file
Write data to a file
Page 48Classification: Restricted
4. Key Java Concepts
i. Constructor
ii. Method overloading
iii. Method overriding
iv. Abstract Class
v. Interface
Page 49Classification: Restricted
i) Constructor
• A constructor is used to initialize a newly created object
• It is implicitly invoked just after the memory is allocated for the object
using ‘new’ keyword
• It is a special method with same name as it’s class name
• No return type for constructor. Not even void
• A constructor without input parameter is default constructor
• Constructor can be overloaded
Page 50Classification: Restricted
ii) Method Overloading
• Reusing the same name for method
• The method calls are resolved at compile time using
method signature.
• Compile time error occurs if compiler cannot match the arguments or if
more than one match is possible
• Method signature consists of
Number of arguments passed to a function
Data types of arguments
Sequence in which they are passed
Page 51Classification: Restricted
Sample Program
class MathEngine
{
public int add(int num1, int num2)
{
….
}
public int add(int num1, int num2, int num3)
{
…
}
}
class Program
{
public static void main(String args[])
{
MathEngine obj = new MathEngine();
int result = obj.add(12,13);
int output = obj.add(15,16,17);
}
}
Page 52Classification: Restricted
iii) Method Overriding
• Polymorphism is achieved using overriding functions using inheritance
• It gives ability to define a behavior that’s specific to the sub class type
based on its requirements
• The version of a method that is executed will be determined by the object
that is used to invoke a method
Parent object ---- > parent method
Child object ----- > child method
Page 53Classification: Restricted
vi) Concrete and Abstract Class
• Concrete class
A class which describes the functionality of an object
It can be instantiated
• Abstract class
A class which contains generic non implemented methods.
Descendant classes comes up with the implementation for those methods in
their own ways
It can contain abstract as well as non abstract methods
Abstract methods do not have implementation
Implementation is left to the inheriting sub classes
Cannot be instantiated
Page 54Classification: Restricted
v) Interface
• An interface defines a contract between a provider and a consumer.
• Enables common design even across those classes not in hierarchy
• Defines a standard set of properties, methods and events.
• Any class implementing an interface has to provide the functionality
Interface
(Some
common
design)
Provider
class
Consumer
class
Implemented
by
Used
by
contract
Page 55Classification: Restricted
Features of an Interface
• Interface is essentially a collection of constants and abstract methods
• The interface approach is sometimes known as “programming by contract”
• Data members in an interface are always public, static and final
• A sub class can only have a single superclass in java but a class can
implement any number of interfaces
• If a class implements an interface then have to implement all the methods
of it.
Page 56Classification: Restricted
6. Strings And Collections
i. String Class – StringBuffer & StringBuilder
ii. Generics & collection
Page 57Classification: Restricted
String class
• Java library contains a predefined class called as String.
• The String type is not a primitive type.
• But in certain cases Java treats it like one
• The ability to declare String literals instead of using new to instantiate a
copy of the class
String s = “seed”
• String is the “First class object”
Page 58Classification: Restricted
String Class
• String class represents an “immutable” string.
• ie. Once an instance is created, the string it contains can not be changed.
• To change the String referenced by a string variable, you throw away the
old string and replace it with the modified one.
“Bye”
“Hello”
New String
Old
String
Page 59Classification: Restricted
StringBuffer Class
• StringBuffer class allows to create “mutable” strings
• It reallocates memory of a given length to accommodate changes within a
same object
• StringBuffer is thread safe
• The buffer grows automatically as characters are added.
Eg StringBuffer sb = new StringBuffer();
Page 60Classification: Restricted
StringBuilder Class
• StringBuilder is introduced in Java 5.0 version.
• This is just an alternative to StringBuffer class.
• There is no difference between StringBuffer and StringBuilder
• Methods of StringBuilder class are not thread safe
• Recommended for faster applications.
Page 61Classification: Restricted
Why collections?
• Array size is fixed. Size cannot be increased dynamically.
• In actual development scenario, same type of objects need to be
processed.
• Data is obtained from data source like files or database.
Page 62Classification: Restricted
Collection – Interface hierarchy Java7
Collection
List Queue Set Map
Deque
Navigable
Set
SortedSet
NavigableMap
SortedMap
Iterator
Page 63Classification: Restricted
Collection Interfaces
• Allow collections to support a different browser
Interface Description
List Represents a collection of objects
that is accessed by an index. An
ordered collection
Set Represents a collection that contains
no duplicate elements. An order is
not fixed
Map Represents a collection of key- value
pairs
Queue Represents a collection designed for
holding elements prior to processing
Iterator Supports a simple iteration over
collection
Comparator Comparison function which imposes
a total ordering on some collection
of objects
Page 64Classification: Restricted
List Interface
• Ordered Collection
• May contain duplicates
• Implemented by classes
-- ArrayList [Resizable – array implementation of the List interface]
-- LinkedList [Doubly linked list implementation of the list]
--Vector [the Vector class implements a growable array of objects]
Page 65Classification: Restricted
Set Interface
• Collection of unique elements
• No duplicate elements allowed
• Collection not in any particular order (random)
• Implemented by the Hashset
Page 66Classification: Restricted
Thank You

More Related Content

What's hot

Structure plug-in introduction for JIRA
Structure plug-in introduction for JIRAStructure plug-in introduction for JIRA
Structure plug-in introduction for JIRA
Dao Ngoc Kien
 
Go Jira
Go JiraGo Jira
Agile Software Development with JIRA and Confluence
Agile Software Development with JIRA and ConfluenceAgile Software Development with JIRA and Confluence
Agile Software Development with JIRA and Confluence
Anand Kumar
 
Introduction To Jira
Introduction To JiraIntroduction To Jira
Introduction To Jira
Hua Soon Sim
 
Jira in action
Jira in actionJira in action
Jira in actionTan Tran
 
Scrum Project Management with Jira as showcase
Scrum Project Management with Jira as showcaseScrum Project Management with Jira as showcase
Scrum Project Management with Jira as showcase
javadch
 
Wikidsmart PM: Requirements Management within Confluence, Integrated with JIRA
Wikidsmart PM: Requirements Management within Confluence, Integrated with JIRAWikidsmart PM: Requirements Management within Confluence, Integrated with JIRA
Wikidsmart PM: Requirements Management within Confluence, Integrated with JIRA
zAgile
 
Why jira
Why jiraWhy jira
Jira
JiraJira
Jira administration Trantor
Jira administration TrantorJira administration Trantor
Jira administration Trantor
Maitrey Patel
 
Application Lifecycle Management with Visual Studio 2013
Application Lifecycle Management  with Visual Studio 2013Application Lifecycle Management  with Visual Studio 2013
Application Lifecycle Management with Visual Studio 2013
Mahmoud Samara
 
VSO & JIRA Project Management Tool
VSO & JIRA Project Management ToolVSO & JIRA Project Management Tool
VSO & JIRA Project Management Tool
Sabaragamuwa University
 
ALM iStack - Application Lifecycle Management using Linked Data
ALM iStack - Application Lifecycle Management using Linked Data ALM iStack - Application Lifecycle Management using Linked Data
ALM iStack - Application Lifecycle Management using Linked Data
Nandana Mihindukulasooriya
 
Introduction to Jira - Bug Tracking tool
Introduction to Jira - Bug Tracking toolIntroduction to Jira - Bug Tracking tool
Introduction to Jira - Bug Tracking tool
Global SQA
 
Introduction to jira
Introduction to jiraIntroduction to jira
Introduction to jiraXpand IT
 
Jira software 8.0 8.5 community presentation
Jira software 8.0 8.5 community presentationJira software 8.0 8.5 community presentation
Jira software 8.0 8.5 community presentation
Maitrey Patel
 
Introduction To Jira Slide Share
Introduction To Jira Slide ShareIntroduction To Jira Slide Share
Introduction To Jira Slide ShareRenjith V
 
Jira as a Project Management Tool
Jira as a Project Management ToolJira as a Project Management Tool
Jira as a Project Management Tool
Paolo Mottadelli
 
PantaRei Design Limited - JIRA Software Introduction - Project - Workflow - D...
PantaRei Design Limited - JIRA Software Introduction - Project - Workflow - D...PantaRei Design Limited - JIRA Software Introduction - Project - Workflow - D...
PantaRei Design Limited - JIRA Software Introduction - Project - Workflow - D...
Francis Yan
 

What's hot (20)

Structure plug-in introduction for JIRA
Structure plug-in introduction for JIRAStructure plug-in introduction for JIRA
Structure plug-in introduction for JIRA
 
Go Jira
Go JiraGo Jira
Go Jira
 
Agile Software Development with JIRA and Confluence
Agile Software Development with JIRA and ConfluenceAgile Software Development with JIRA and Confluence
Agile Software Development with JIRA and Confluence
 
Introduction To Jira
Introduction To JiraIntroduction To Jira
Introduction To Jira
 
Jira in action
Jira in actionJira in action
Jira in action
 
Jira
JiraJira
Jira
 
Scrum Project Management with Jira as showcase
Scrum Project Management with Jira as showcaseScrum Project Management with Jira as showcase
Scrum Project Management with Jira as showcase
 
Wikidsmart PM: Requirements Management within Confluence, Integrated with JIRA
Wikidsmart PM: Requirements Management within Confluence, Integrated with JIRAWikidsmart PM: Requirements Management within Confluence, Integrated with JIRA
Wikidsmart PM: Requirements Management within Confluence, Integrated with JIRA
 
Why jira
Why jiraWhy jira
Why jira
 
Jira
JiraJira
Jira
 
Jira administration Trantor
Jira administration TrantorJira administration Trantor
Jira administration Trantor
 
Application Lifecycle Management with Visual Studio 2013
Application Lifecycle Management  with Visual Studio 2013Application Lifecycle Management  with Visual Studio 2013
Application Lifecycle Management with Visual Studio 2013
 
VSO & JIRA Project Management Tool
VSO & JIRA Project Management ToolVSO & JIRA Project Management Tool
VSO & JIRA Project Management Tool
 
ALM iStack - Application Lifecycle Management using Linked Data
ALM iStack - Application Lifecycle Management using Linked Data ALM iStack - Application Lifecycle Management using Linked Data
ALM iStack - Application Lifecycle Management using Linked Data
 
Introduction to Jira - Bug Tracking tool
Introduction to Jira - Bug Tracking toolIntroduction to Jira - Bug Tracking tool
Introduction to Jira - Bug Tracking tool
 
Introduction to jira
Introduction to jiraIntroduction to jira
Introduction to jira
 
Jira software 8.0 8.5 community presentation
Jira software 8.0 8.5 community presentationJira software 8.0 8.5 community presentation
Jira software 8.0 8.5 community presentation
 
Introduction To Jira Slide Share
Introduction To Jira Slide ShareIntroduction To Jira Slide Share
Introduction To Jira Slide Share
 
Jira as a Project Management Tool
Jira as a Project Management ToolJira as a Project Management Tool
Jira as a Project Management Tool
 
PantaRei Design Limited - JIRA Software Introduction - Project - Workflow - D...
PantaRei Design Limited - JIRA Software Introduction - Project - Workflow - D...PantaRei Design Limited - JIRA Software Introduction - Project - Workflow - D...
PantaRei Design Limited - JIRA Software Introduction - Project - Workflow - D...
 

Similar to Core Java for Selenium

Object oriented programming
Object oriented programmingObject oriented programming
Introduction to OOP concepts
Introduction to OOP conceptsIntroduction to OOP concepts
Introduction to OOP concepts
Ahmed Farag
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
RatnaJava
 
2CPP09 - Encapsulation
2CPP09 - Encapsulation2CPP09 - Encapsulation
2CPP09 - Encapsulation
Michael Heron
 
Questpond - Top 10 Interview Questions and Answers on OOPS
Questpond - Top 10 Interview Questions and Answers on OOPSQuestpond - Top 10 Interview Questions and Answers on OOPS
Questpond - Top 10 Interview Questions and Answers on OOPS
gdrealspace
 
UNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptxUNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptx
anguraju1
 
Need of object oriented programming
Need of object oriented programmingNeed of object oriented programming
Need of object oriented programming
Amar Jukuntla
 
1_Object Oriented Programming.pptx
1_Object Oriented Programming.pptx1_Object Oriented Programming.pptx
1_Object Oriented Programming.pptx
umarAnjum6
 
Hibernate basics
Hibernate basicsHibernate basics
Hibernate basics
AathikaJava
 
Java Hibernate Basics
Java Hibernate BasicsJava Hibernate Basics
Java Hibernate Basics
DeeptiJava
 
Java OOP s concepts and buzzwords
Java OOP s concepts and buzzwordsJava OOP s concepts and buzzwords
Java OOP s concepts and buzzwords
Raja Sekhar
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
AathikaJava
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
DeeptiJava
 
Principles of OOPs.pptx
Principles of OOPs.pptxPrinciples of OOPs.pptx
Principles of OOPs.pptx
LakshyaChauhan21
 
Design Pattern lecture 1
Design Pattern lecture 1Design Pattern lecture 1
Design Pattern lecture 1
Julie Iskander
 
U1 JAVA.pptx
U1 JAVA.pptxU1 JAVA.pptx
U1 JAVA.pptx
madan r
 
Introduction
IntroductionIntroduction
Introduction
Preeti Mishra
 
Wahckon[2] - iOS Runtime Hacking Crash Course
Wahckon[2] - iOS Runtime Hacking Crash CourseWahckon[2] - iOS Runtime Hacking Crash Course
Wahckon[2] - iOS Runtime Hacking Crash Course
eightbit
 
Features of Object Oriented Programming.pptx
Features of Object Oriented Programming.pptxFeatures of Object Oriented Programming.pptx
Features of Object Oriented Programming.pptx
SwagatoBiswas
 
Session 07 - Intro to Object Oriented Programming with Java
Session 07 - Intro to Object Oriented Programming with JavaSession 07 - Intro to Object Oriented Programming with Java
Session 07 - Intro to Object Oriented Programming with Java
PawanMM
 

Similar to Core Java for Selenium (20)

Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Introduction to OOP concepts
Introduction to OOP conceptsIntroduction to OOP concepts
Introduction to OOP concepts
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
 
2CPP09 - Encapsulation
2CPP09 - Encapsulation2CPP09 - Encapsulation
2CPP09 - Encapsulation
 
Questpond - Top 10 Interview Questions and Answers on OOPS
Questpond - Top 10 Interview Questions and Answers on OOPSQuestpond - Top 10 Interview Questions and Answers on OOPS
Questpond - Top 10 Interview Questions and Answers on OOPS
 
UNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptxUNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptx
 
Need of object oriented programming
Need of object oriented programmingNeed of object oriented programming
Need of object oriented programming
 
1_Object Oriented Programming.pptx
1_Object Oriented Programming.pptx1_Object Oriented Programming.pptx
1_Object Oriented Programming.pptx
 
Hibernate basics
Hibernate basicsHibernate basics
Hibernate basics
 
Java Hibernate Basics
Java Hibernate BasicsJava Hibernate Basics
Java Hibernate Basics
 
Java OOP s concepts and buzzwords
Java OOP s concepts and buzzwordsJava OOP s concepts and buzzwords
Java OOP s concepts and buzzwords
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
 
Principles of OOPs.pptx
Principles of OOPs.pptxPrinciples of OOPs.pptx
Principles of OOPs.pptx
 
Design Pattern lecture 1
Design Pattern lecture 1Design Pattern lecture 1
Design Pattern lecture 1
 
U1 JAVA.pptx
U1 JAVA.pptxU1 JAVA.pptx
U1 JAVA.pptx
 
Introduction
IntroductionIntroduction
Introduction
 
Wahckon[2] - iOS Runtime Hacking Crash Course
Wahckon[2] - iOS Runtime Hacking Crash CourseWahckon[2] - iOS Runtime Hacking Crash Course
Wahckon[2] - iOS Runtime Hacking Crash Course
 
Features of Object Oriented Programming.pptx
Features of Object Oriented Programming.pptxFeatures of Object Oriented Programming.pptx
Features of Object Oriented Programming.pptx
 
Session 07 - Intro to Object Oriented Programming with Java
Session 07 - Intro to Object Oriented Programming with JavaSession 07 - Intro to Object Oriented Programming with Java
Session 07 - Intro to Object Oriented Programming with Java
 

More from Rajathi-QA

HP ALM
HP ALMHP ALM
HP ALM
Rajathi-QA
 
Selenium WebDriver
Selenium WebDriverSelenium WebDriver
Selenium WebDriver
Rajathi-QA
 
Quick Test Professional (QTP/UFT)
Quick Test Professional (QTP/UFT)Quick Test Professional (QTP/UFT)
Quick Test Professional (QTP/UFT)
Rajathi-QA
 
Other Testing Types
Other Testing TypesOther Testing Types
Other Testing Types
Rajathi-QA
 
Introduction to Software Testing
Introduction to Software TestingIntroduction to Software Testing
Introduction to Software Testing
Rajathi-QA
 
Defects and Categories
Defects and CategoriesDefects and Categories
Defects and Categories
Rajathi-QA
 
Test Execution
Test ExecutionTest Execution
Test Execution
Rajathi-QA
 

More from Rajathi-QA (7)

HP ALM
HP ALMHP ALM
HP ALM
 
Selenium WebDriver
Selenium WebDriverSelenium WebDriver
Selenium WebDriver
 
Quick Test Professional (QTP/UFT)
Quick Test Professional (QTP/UFT)Quick Test Professional (QTP/UFT)
Quick Test Professional (QTP/UFT)
 
Other Testing Types
Other Testing TypesOther Testing Types
Other Testing Types
 
Introduction to Software Testing
Introduction to Software TestingIntroduction to Software Testing
Introduction to Software Testing
 
Defects and Categories
Defects and CategoriesDefects and Categories
Defects and Categories
 
Test Execution
Test ExecutionTest Execution
Test Execution
 

Recently uploaded

Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 

Recently uploaded (20)

Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 

Core Java for Selenium

  • 1. Quality Assurance / Software Testing Training Core Java for Selenium
  • 2. Page 2Classification: Restricted Agenda • Java Fundamentals • Introduction to Java • Programming Language fundamentals • Key Java Concepts • Strings and collections
  • 3. Page 3Classification: Restricted 1. Java Fundamentals i. History of Java ii. Features of java iii. Introduction to OOPs
  • 4. Page 4Classification: Restricted i. History of Java • Background: Electronic Consumer Device • Sun Commissioned ‘Project Green’ • Developed language ‘Oak-Later renamed to Java’ • Invented by Dr.James A.Gosling and his team in 1994 • Was dismissed as just another OO programming language • Became popular with the rising popularity of ‘www’
  • 5. Page 5Classification: Restricted ii. Features of Java • Simple • Robust • Distributed • Secure • Portable • Interpreted • Multithreaded • Portable • Object Oriented
  • 6. Page 6Classification: Restricted Simple • Java designed as closely to C++ as possible • Omits many confusing and rarely used features : No header files Structures Unions Pointers Operator overloading Virtual base class etc..
  • 7. Page 7Classification: Restricted Robust • Java Programs are reliable • Early checking for potential problems • Dynamic checking to eliminate error-prone situations. • Developer doesn’t have to worry about Bad Pointers Memory Allocation Errors Memory Leakage
  • 8. Page 8Classification: Restricted Distributed • An application when divided into smaller units is called as distributed system • Extensive library support protocols like TCP/IP, HTTP & FTP • Applications can access objects across the net with ease. Creating socket connections Servlets CGI Scripting RMI enables communication between different objects
  • 9. Page 9Classification: Restricted Platform Independence .java file Intermediate language code abc.java abc.class • Java compiler generates byte code Platform independent Bytecode code is an architecture-neutral file format to transport code efficiently independent of hardware and Operating systems The use of the same bytecode for all JVMs on all platforms Allows Java to be described as a “compile once, run everywhere” programming language Source Code Compile Byte Code Window Linux Mac
  • 10. Page 10Classification: Restricted Secure • Java applications used in distributed environments require emphasis on memory Security Manager Allows applications to implement a security policy before performing a possible unsafe or sensitive operation. ByteCode Verifier ByteCode Verifier is responsible for verifying the byte codes. ByteCode do not violate Java’s security restrictions.
  • 11. Page 11Classification: Restricted Portable • Behavior of java basic types & arithmetic operators is consistent • Java programs’s behavior is same on every platform – no data type incompatibilities across platforms.  int is always a 32-bit int Strings stored in standard Unicode format
  • 12. Page 12Classification: Restricted Interpreted • ByteCode can be executed on any machine that has java interpreter and java run time system • Classes are linked only on need basis • Java is both compiled and interpreted
  • 13. Page 13Classification: Restricted iii) Object Oriented Approach • Key concepts of object oriented programming are • Abstraction • Encapsulation • Inheritance • Polymorphism
  • 14. Page 14Classification: Restricted Abstraction • Abstraction is the process of identifying the key aspects of an entity and ignoring the rest • Only those aspects are selected that are important to the current problem scenario • Eg) Abstraction of a person object • Enumerate attributes of a “person object” that needs to be created for developing a database • Useful for social survey • Useful for health care industry • Useful for payroll system
  • 15. Page 15Classification: Restricted Abstraction of a Person Object Social Survey Health Care Payroll System Name Name Name Age Age Age Marital status -- -- Religion -- -- Income group -- -- Address Address Address Occupation occupation Occupation -- Blood group -- -- Weight -- -- Previous record -- -- -- Basic salary -- -- Department -- -- Qualification
  • 16. Page 16Classification: Restricted Abstraction :Process of identifying the key aspects of an entity & ignoring the rest Encapsulation: Ensures that data within an object is protected and accessed only by its methods
  • 17. Page 17Classification: Restricted Encapsulation • Encapsulation is a mechanism used to hide the data, internal structure and implementation details of an object • All interaction with the object is through the public interface of operations • The user knows only about the interface, any changes to the implementation does not affect the user Methods Variables
  • 18. Page 18Classification: Restricted What is an Object? • An entity is an entity which has a well defined structure and behaviour. An object possesses certain characteristics as: • State • Behavior • Identity
  • 19. Page 19Classification: Restricted State of an Object • The state of an object includes the current values of all its attributes. • An attribute can be static or dynamic • Employee Attributes empid name static gender Age Address Phone Basicsal dynamic Education experience
  • 20. Page 20Classification: Restricted Behavior of the Object • Behavior is how an object acts and reacts, in terms of its changes and message passing Employee as an object calculateSalary printDetails Employee Totality of operations – how an employee behaves or responds to, is the behavior of the person.
  • 21. Page 21Classification: Restricted Identity of an Object • Identity is that property of an object which distinguishes it from all other objects • A single or a group of attributes can be an identity of an object Employee empId Name Gender Phone Age Address Phone Basicsal Education empId uniquely identifies a person among others
  • 22. Page 22Classification: Restricted Person as an Object Attributes State Identity Behavior empID empId = 10 empId = 10 Swipe Card Name Name = “Dhruv” Fill TimeSheet Gender Gender = “male” Wear Icard Age Age=27 Calculate Salary Address Address = “pune” Print details Phone Phone = 2342432 basicSalary basicSalary=80 00 Education experience
  • 23. Page 23Classification: Restricted Inheritance • Classification helps in handling complexity • Inheritance is the process by which one object acquire the properties of another object • “is a ”kind of hierarchy Person Employee Wage Employee Manager Sales Person
  • 24. Page 24Classification: Restricted Inheritance • Generalization Factoring out common elements within a set of categories into a more general category called super class. Requires good skill of abstraction • Specialization Allows to capture specific features of a set of objects. Requires a depth of knowledge of domain.
  • 25. Page 25Classification: Restricted Polymorphism • The ability of different types of related objects to respond to the same message in their own ways is called polymorphism • Polymorphism helps to design extensible software, as new objects can be added to the design without rewriting existing procedures
  • 26. Page 26Classification: Restricted Polymorphism: same method having different implementations • Compile/ static polymorphism – by function overloading • Run time polymorphism – by function overriding
  • 27. Page 27Classification: Restricted 2. Introduction to Java i. Compilation & execution of Java Program ii. JDK, JVM & JRE iii. Class & Object iv. Access Modifiers v. Data type vi. Java class syntax
  • 28. Page 28Classification: Restricted i) Compilation & Execution of Java Program .java file Java Class libraries JDK JRE Source code compiler Byte code Class loader ByteCode verifier Interpreter Native OS JVM awt net rmii/o
  • 29. Page 29Classification: Restricted ii) JDK, JVM and JRE • JDK (Java Development Kit) Comes along with standard class libraries and JVM embedded in it. Contains software development tools such as a compiler or a debugger which are used to compile and run the Java program. • JRE(Java Runtime Environment) It is an implementation of JVM, which actually executes the Java program JRE provides some standard libraries and the JVM which can be used to execute the java program • JVM(Java Virtual Machine) • JVM loads the appropriate class files for execution the java program and then execute it • JVM is a : - Abstract specification - A concrete implementation or - A runtime instance
  • 30. Page 30Classification: Restricted iii) Anatomy of JAVA class • The term ‘class’ comes from the word called ‘classification’ • A class is a template for creation of like objects • An object is an instance of class • Classes are used to map real world entities into data members and member functions • By writing a class and creating objects of the class one can map two key concepts of major pillars of object msodel i.e. Abstraction and Encapsulation
  • 31. Page 31Classification: Restricted Class: A class is a template for the creation of like objects
  • 33. Page 33Classification: Restricted iv) Access Modifiers • Access modifiers allow to specify the scope of the class members. We use access modifiers to define the access control for classes, methods and variables • Access modifiers are of 4 types: private – is accessible only within class default – if we don’t specify any modifier then it is treated as default, this can be accessible only within package protected – is accessible within package , outside of the package but through inheritance only public – is accessible anywhere • Non Access Modifiers Static Final : more like constant in C
  • 34. Page 34Classification: Restricted Modifier Within Class Within Package Outside of Package (By Sub Class) Outside of Package Private Y N N N default Y Y N N protected Y Y Y N public Y Y Y Y
  • 35. Page 35Classification: Restricted v) Data Types : Is the classification of the type of data that variable can hold in computer programming Primitive Data Type Boolean Type Numeric Type boolean Integral Type Floating Point Type float double Characte r Type Integer Type char longbyte short int
  • 36. Page 36Classification: Restricted vi) Java Class Syntax By Convention: class Class_Name class name starts with capital case { e.g. class MySample variable_Declaration; variable(attribute or property) method_Declaration() { name starts with small case ….. e.g. int date ….. } public static void main(String args[]) Method(behavior) name starts with { first word small case then next …. Words 1st letter capital case called …. Camel case } //end of class e.g. void printDate() { }
  • 37. Page 37Classification: Restricted First Java Class /* This is a comment */ //This is another comment class MyDate { private int day, month, year; //variable public void initDate() //method 1 { day = 30; month = 6; year =2011; } public void printDate() //method 2 { System.out.println(“Date is:” + day +”/” + month +”/” +year); }
  • 38. Page 38Classification: Restricted Create an Object //continuation public static void main(String args[]) { MyDate d = new MyDate(); //method invocation d.initDate(); d.printDate(); } }
  • 39. Page 39Classification: Restricted 3. Language Fundamentals i. Operators in Java ii. Conditional & Loop statements iii. Arrays in Java iv. Exception handling v. File handling
  • 40. Page 40Classification: Restricted i) Operators • Arithmetic operators Addition, Subtraction, Multiplication, Division, Modulus, Increment, Decrement • Relational operators == , != , > , >= , < , <= • Logical operators Logical Not Operator ! Logical AND Operator && Logical OR Operator || • Assignment operators =
  • 41. Page 41Classification: Restricted ii) Java Conditional & Loop statements • Single Conditional statements if(a>b) { .. } • Compound Conditional statements If((a>b) && (a<c)) { .. } • Nested Conditions if(a<b) { if(a<c) { if(a>b) { } } } • Java Switch statement : executes one statement from multiple conditions.
  • 42. Page 42Classification: Restricted Loop Statements • Loop statements are used to iterate a part of the program several times. • Three types of loops For loop for(initialization ; condition ;incr / decr){ //code to be executed } While loop while(condition){ //code to be executed } Do.. While loop do{ //code to be executed }while(condition);
  • 43. Page 43Classification: Restricted Break, Continue & Comments • Break statement The Java break is used to break loop or switch statement. It breaks the current flow of the program at specified condition. In case of inner loop, it breaks only inner loop. • Continue statement The Java continue statement is used to continue loop. It continues the current flow of the program and skips the remaining code at specified condition. In case of inner loop, it continues only inner loop. Comments in Java: The java comments are statements that are not executed by the compiler and interpreter. The comments can be used to provide information or explanation about the variable, method, class or any statement. It can also be used to hide program code for specific time.
  • 44. Page 44Classification: Restricted iii) Arrays in Java Normally, array is a collection of similar type of elements that have contiguous memory location. Java array is an object the contains elements of similar data type • Advantage: Code Optimization Random access • Disadvantage: Size limit Types of Array: • Single dimensional • Multi dimensional
  • 45. Page 45Classification: Restricted iv. Exception Handling • There is no perfect world • Errors are inevitable • Errors are shipped even with the best software • Occur due to Wrong input Error on platform or system not configured Program bugs • Occur when the software is operational
  • 46. Page 46Classification: Restricted Types of Errors • Logical Errors Counter not incremented in the while loop Wrong expression written, resulting in incorrect output • Run time Errors Division by Zero Array out of bounds Dynamic memory allocation failed File not found File is corrupt
  • 47. Page 47Classification: Restricted v) File Handling in Java • High level operations/External operation Create a folder Delete a folder Create a text file Delete a text file • Low level operations/ Internal operation Read data from a file Write data to a file
  • 48. Page 48Classification: Restricted 4. Key Java Concepts i. Constructor ii. Method overloading iii. Method overriding iv. Abstract Class v. Interface
  • 49. Page 49Classification: Restricted i) Constructor • A constructor is used to initialize a newly created object • It is implicitly invoked just after the memory is allocated for the object using ‘new’ keyword • It is a special method with same name as it’s class name • No return type for constructor. Not even void • A constructor without input parameter is default constructor • Constructor can be overloaded
  • 50. Page 50Classification: Restricted ii) Method Overloading • Reusing the same name for method • The method calls are resolved at compile time using method signature. • Compile time error occurs if compiler cannot match the arguments or if more than one match is possible • Method signature consists of Number of arguments passed to a function Data types of arguments Sequence in which they are passed
  • 51. Page 51Classification: Restricted Sample Program class MathEngine { public int add(int num1, int num2) { …. } public int add(int num1, int num2, int num3) { … } } class Program { public static void main(String args[]) { MathEngine obj = new MathEngine(); int result = obj.add(12,13); int output = obj.add(15,16,17); } }
  • 52. Page 52Classification: Restricted iii) Method Overriding • Polymorphism is achieved using overriding functions using inheritance • It gives ability to define a behavior that’s specific to the sub class type based on its requirements • The version of a method that is executed will be determined by the object that is used to invoke a method Parent object ---- > parent method Child object ----- > child method
  • 53. Page 53Classification: Restricted vi) Concrete and Abstract Class • Concrete class A class which describes the functionality of an object It can be instantiated • Abstract class A class which contains generic non implemented methods. Descendant classes comes up with the implementation for those methods in their own ways It can contain abstract as well as non abstract methods Abstract methods do not have implementation Implementation is left to the inheriting sub classes Cannot be instantiated
  • 54. Page 54Classification: Restricted v) Interface • An interface defines a contract between a provider and a consumer. • Enables common design even across those classes not in hierarchy • Defines a standard set of properties, methods and events. • Any class implementing an interface has to provide the functionality Interface (Some common design) Provider class Consumer class Implemented by Used by contract
  • 55. Page 55Classification: Restricted Features of an Interface • Interface is essentially a collection of constants and abstract methods • The interface approach is sometimes known as “programming by contract” • Data members in an interface are always public, static and final • A sub class can only have a single superclass in java but a class can implement any number of interfaces • If a class implements an interface then have to implement all the methods of it.
  • 56. Page 56Classification: Restricted 6. Strings And Collections i. String Class – StringBuffer & StringBuilder ii. Generics & collection
  • 57. Page 57Classification: Restricted String class • Java library contains a predefined class called as String. • The String type is not a primitive type. • But in certain cases Java treats it like one • The ability to declare String literals instead of using new to instantiate a copy of the class String s = “seed” • String is the “First class object”
  • 58. Page 58Classification: Restricted String Class • String class represents an “immutable” string. • ie. Once an instance is created, the string it contains can not be changed. • To change the String referenced by a string variable, you throw away the old string and replace it with the modified one. “Bye” “Hello” New String Old String
  • 59. Page 59Classification: Restricted StringBuffer Class • StringBuffer class allows to create “mutable” strings • It reallocates memory of a given length to accommodate changes within a same object • StringBuffer is thread safe • The buffer grows automatically as characters are added. Eg StringBuffer sb = new StringBuffer();
  • 60. Page 60Classification: Restricted StringBuilder Class • StringBuilder is introduced in Java 5.0 version. • This is just an alternative to StringBuffer class. • There is no difference between StringBuffer and StringBuilder • Methods of StringBuilder class are not thread safe • Recommended for faster applications.
  • 61. Page 61Classification: Restricted Why collections? • Array size is fixed. Size cannot be increased dynamically. • In actual development scenario, same type of objects need to be processed. • Data is obtained from data source like files or database.
  • 62. Page 62Classification: Restricted Collection – Interface hierarchy Java7 Collection List Queue Set Map Deque Navigable Set SortedSet NavigableMap SortedMap Iterator
  • 63. Page 63Classification: Restricted Collection Interfaces • Allow collections to support a different browser Interface Description List Represents a collection of objects that is accessed by an index. An ordered collection Set Represents a collection that contains no duplicate elements. An order is not fixed Map Represents a collection of key- value pairs Queue Represents a collection designed for holding elements prior to processing Iterator Supports a simple iteration over collection Comparator Comparison function which imposes a total ordering on some collection of objects
  • 64. Page 64Classification: Restricted List Interface • Ordered Collection • May contain duplicates • Implemented by classes -- ArrayList [Resizable – array implementation of the List interface] -- LinkedList [Doubly linked list implementation of the list] --Vector [the Vector class implements a growable array of objects]
  • 65. Page 65Classification: Restricted Set Interface • Collection of unique elements • No duplicate elements allowed • Collection not in any particular order (random) • Implemented by the Hashset