Java Object Oriented Programming Part 2

preview_player
Показать описание
Java OOPS, Inheritance, Polymorphism, Abstraction and Encapsulation. Java Abstract classes, inheriting abstract classes, Java Interfaces, inheriting Java interface methods and part of Encapsulation creating getter and setter methods.
Рекомендации по теме
Комментарии
Автор

Class Notes:
Java Object Oriented Programming Part-2

Java OOPS (Object Oriented Programming System)

i) Inheritance

ii) Polymorphism

iii) Abstraction

iv) Encapsulation

iii) Abstraction

> It is process of hiding implementation details and showing only functionality to the user.

Two types of methods

i) Concrete Methods (The methods which are having body)

Syntax:

accessModifier returnType/returnTypeNothing methodName(){
Statements


}

ii) Abstract Methods (The methods which are not having body)

Syntax:

accessModifier abstract returnType/returnTypeNothing methodName();

> if we know the method name, but don't know the method functionality then we can go for abstract methods

> Java Class contains 100% concrete methods

> Abstract Class contains one or more abstract methods.

Example:

Class1 (having 10 methods)

10 methods are concrete methods

Java Class

Class2 (having 10 methods)

5 methods are concrete methods and 5 methods are abstract methods

Abstract Class

Class3 (having 10 methods)

All 10 methods are abstract methods.

Abstract Class

Example for Abstract Class:

public abstract class Bikes {
public void handle(){
System.out.println("Bikes have Handle");
}
public void seat(){
System.out.println("Bikes have Seats");
}
public abstract void engine();

public abstract void wheels();

public static void main(String[] args) {
//Bikes obj = new Bikes();
}
}

Note:
1) We cannot create object in abstract class
2) In order to use Methods from abstract class then first we need implement abstract methods
in sub class

Reusing Abstract methods in sub class

public class HeroHonda extends Bikes{
public void engine() {
System.out.println("Bikes have Engine");
}
public void wheels() {
System.out.println("Bikes have Wheels");
}
public static void main(String[] args) {
HeroHonda abc = new HeroHonda();
abc.engine();
abc.handle();
abc.wheels();
abc.seat();
}

Use Methods in Parent / Abstract Class

public abstract class Bikes {
public void handle(){
System.out.println("Bikes have Handle");
}
public void seat(){
System.out.println("Bikes have Seats");
}
public abstract void engine();

public abstract void wheels();

public static void main(String[] args) {
HeroHonda obj = new HeroHonda();
obj.seat();
obj.wheels();
}
}

How to inherit Abstract class Methods?

By implementing abstract methods in sub class.

How to call methods in Abstract Class?

By creating Object/Instance using Sub Class.

Java Interfaces

> Interface is a Java type definition block which 100% abstract

i) Class Vs. Abstract Class

Java Classes have 100% concrete Methods

Abstract Classes have one or more/all abstract methods

ii) Class Vs. Interface

Java Classes have 100% concrete Methods

Java Interface have 100% abstract methods

iii) Abstract Class Vs. Interface

Abstract Classes have one or more/all abstract methods

Java Interfaces have 100% abstract methods

> All interface methods by default public and abstract
> static and final modifiers are not allowed for abstract methods
> In Interfaces, Variables have to initialize at the time of declaration only.

Ex:
int a=100; //Correct

int b;
b=200; //Incorrect

> In Interfaces, Variables are public and final by default.
> Interfaces are going to be used using "implements" keyword

Create Java Interface

Java Project
Java Package
Java Class / Java Interface

example:

public interface Interface1 {
public void engine();
public void seat();
public void wheels();
}

Reuse Methods from Interface to Class

public class Class1 implements Interface1 {

public void engine() {
System.out.println("Bikes have Engine");
}
public void seat() {
System.out.println("Bikes have Seat");
}

public void wheels() {
System.out.println("Bikes have Wheels");
}
public static void main (String [] args){
Class1 obj = new Class1();
obj.wheels();
obj.engine();
}
}

Call Methods in Interface

public class Class1 implements Interface1 {

public void engine() {
System.out.println("Bikes have Engine");
}
public void seat() {
System.out.println("Bikes have Seat");
}

public void wheels() {
System.out.println("Bikes have Wheels");
}
public static void main (String [] args){
Class1 obj = new Class1();
obj.wheels();
obj.engine();
}
}

Reuse Methods from a Class to another Class - using "extends" keyword

Reuse Methods from Abstract Class to a Class - using "extends" keyword
(* Need to implement abstract methods in the class/sub)

Reuse Methods for an Interface to a Class - using "implements" keyword.

Assignment

How to reuse Methods from an Interface to another.

iv) Encapsulation

It is a process of wrapping code and data into a single unit.

General example:

Capsule (Mixer for several medicines)

Encapsulation is the technique making the fields in class private and providing access via public methods

> It provides control over the data.

> By providing setter and getter methods we can make a class read only or write only

Example:

Class 1:

public class Class1 {
private String name ="Test Automation using UFT/QTP";

public String getName(){
return name;
}

public void setName (String newName){
name = newName;
}
public static void main(String[] args) {
Class1 obj = new Class1();
obj.setName("Test Automation using Selenium");

}
}

Class 2:

public class Class2 extends Class1 {

public static void main(String[] args) {
Class2 obj2 = new Class2();
//obj2.setName("Hello Java");

}
}

Java for Selenium

Java Environment Setup

A) Java Fundamentals
i) Writing Comments
ii) Data Types
iii) Modifiers
iv) Variables
v) Operators
vi) Conditional Statements
vii) Loop Statements
viii) String handling
ix) Arrays
x) File Handling
xi) Exception Handling
xii) Predefined methods
xiii) User defined Methods

B) Java Object Oriented Programming

i) Inheritance
ii) Polymorphism
iii) Abstraction
iv) Encapsulation

Software Test Process

i) Manual Testing
ii) Automated Testing / Test Automation

Manual Test Process

> Understanding and Analyzing Test Requirements
> Test Planning
> Test Case Development and Test Data collection
> Test Execution, Defect Reporting and Tracking
> Regression Testing
> Test Closure

Automated Test Process (Functional Testing) using UFT or Selenium etc...

> Test Planning (Analyzing the AUT, Test Environment Setup etc...)
> Test Design (Creating Test Cases using Tool features and Programming features)
> Run and Debug Tests
(Cross Browser Testing, batch Testing, Data Driven Testing, Database Testing and Parallel Test execution.)
> Analyze Test Results and Report Defects

Automated Test Process (Performance Testing) using LoadRunner or JMeter etc...

> Test Planning (Test environment Setup etc...)
> Create Test Scripts for Single user and run them once.
> Create Virtual users and apply multiple users Load
> Run Tests
> Analysis (Analyze the Test Result)

Software Test Types
Functional Testing
Functionality Testing
Security Testing etc...
Non Functional Testing
Performance Testing (Load Testing, Stress Testing, Spike Testing, Endurance Testing...)
Usability Testing
Recovery Testing
Localization Testing
Internationalization Testing Etc...

Test Management Tasks

Requirements Management

Test Case Management

Defect Management etc...

gcreddy
welcome to shbcf.ru