Difference between revisions of "Java"

From Script | Spoken-Tutorial
Jump to: navigation, search
(Basic Level)
(Introduction)
(15 intermediate revisions by 5 users not shown)
Line 8: Line 8:
  
 
<blockquote style="background-color: lemonchiffon; border: solid thin grey;">
 
<blockquote style="background-color: lemonchiffon; border: solid thin grey;">
[[Media:JavaTemplate.zip | Java Slide Template]]  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
 
 
[[Glossary_for_Java | Glossary]]
 
[[Glossary_for_Java | Glossary]]
 
</blockquote>
 
</blockquote>
Line 26: Line 25:
 
#*Run a simple java program and see if it works
 
#*Run a simple java program and see if it works
 
#*Type javac TestProgram.java for compiling the code and java TestProgram for executing the code
 
#*Type javac TestProgram.java for compiling the code and java TestProgram for executing the code
 +
#Java - First program
 +
#*write simple java program
 +
#*print “My First Java Program!” on Console
 +
#*save the file
 +
#*file name given to the java file
 +
#*compile the file
 +
#*run the file
 +
#*correct the errors
 +
#*naming conventions for class
 +
#*naming conventions for method
 +
#*naming conventions for variable
 
#:<br>
 
#:<br>
#*Java - First program
+
#:'''Eclipse'''
#**write simple java program
+
#Installing Eclipse  
#**print “My First Java Program!” on Console
+
#*Install Eclipse on Ubuntu on the Terminal
#**save the file
+
#*Set up the proxy on the Terminal  
#**file name given to the java file
+
#*Then fetch the list of all the available softwares
#**compile the file
+
#*Type sudo apt-get update
#**run the file
+
#*Then install eclipse on the Terminal
#**correct the errors
+
#*Type sudo apt-get install eclipse
#**naming conventions for class
+
#*Verify if Eclipse is installed on the system
#**naming conventions for method
+
#*Installing Eclipse on Debian,Kubuntu,Xubuntu
#**naming conventions for variable
+
#*Installing Eclipse on Redhat  
#Eclipse
+
#*Installing Eclipse on Fedora,centos and suse linux
#*Installing Eclipse  
+
#Getting started with Eclipse
#**Install Eclipse on Ubuntu on the Terminal
+
#*Eclipse is an Integrated Development Environment
#**Set up the proxy on the Terminal  
+
#*It is a tool on which one can write, debug and run java programs easily
#**Then fetch the list of all the available softwares
+
#*Open Dash Home and type Eclipse in the search box.
#**Type sudo apt-get update
+
#*We get Workspace Launcher
#**Then install eclipse on the Terminal
+
#*On clicking on Workbench we get the Eclipse IDE
#**Type sudo apt-get install eclipse
+
#*Go to File->New->Project and select Java Project
#**Verify if Eclipse is installed on the system
+
#*Create a project named EclipseDemo and create a class inside DemoClass
#**Installing Eclipse on Debian,Kubuntu,Xubuntu
+
#*Learn about Package Explorer and Editor portlet
#**Installing Eclipse on Redhat  
+
#Hello World Program
#**Installing Eclipse on Fedora,centos and suse linux
+
#*Open Eclipse
#*Getting started with Eclipse
+
#*Create a Java Project named DemoProject
#**Eclipse is an Integrated Development Environment
+
#*Create a class named DemoClass
#**It is a tool on which one can write, debug and run java programs easily
+
#*Class name and file name will be the same
#**Open Dash Home and type Eclipse in the search box.
+
#*Eclipse suggests various possibilities as we type a command
#**We get Workspace Launcher
+
#*Eclipse also completes the parentheses by automatically adding the closing parentheses
#**On clicking on Workbench we get the Eclipse IDE
+
#*Include the statement that we want to print
#**Go to File->New->Project and select Java Project
+
#*Eclipse also completes the quotes by adding the closing quote
#**Create a project named EclipseDemo and create a class inside DemoClass
+
#*Compile and execute the program
#**Learn about Package Explorer and Editor portlet
+
#*Change the code to print<br/>  
#**Add the println statement in<br/>
+
#Errors and Debugging
#* Hello World Program
+
#*When writing a Java Program, here is a list of typical errors:
#**Open Eclipse
+
#*Missing semicolon(;)
#**Create a Java Project named DemoProject
+
#*Missing double quotes(".")
#**Create a class named DemoClass
+
#*Mis-match of filename and classname
#**Class name and file name will be the same
+
#*Typing the print statement n lower case
#**Eclipse suggests various possibilities as we type a command
+
#*The line which has the error will be indicated with a red cross mark on the left margin
#**Eclipse also completes the parentheses by automatically adding the closing parentheses
+
#*The list of errors is displayed by hovering the mouse over the cross mark
#**Include the statement that we want to print
+
#*Create a class ErrorFree with Errors, debug the code and run it
#**Eclipse also completes the quotes by adding the closing quote
+
#*Eclipse also offers intelligent fixes<br/>  
#**Compile and execute the program
+
#Programming features of Eclipse
#**Change the code to print<br/>  
+
#*Auto completion
#*Errors and Debugging
+
#*Sets the corresponding closing brace when we open the brace
#**When writing a Java Program, here is a list of typical errors:
+
#*Provides a drop-down list of methods when you start typing the code.
#**Missing semicolon(;)
+
#*Syntax highlighting
#**Missing double quotes(".")
+
#*Classname is highlighted in pink color and method in blue color.
#**Mis-match of filename and classname
+
#*Keyboard shortcuts
#**Typing the print statement n lower case
+
#*F11 to debug a program and Ctrl plus H to search a specific file.
#**The line which has the error will be indicated with a red cross mark on the left margin
+
#*Error highlighting
#**The list of errors is displayed by hovering the mouse over the cross mark
+
#*Cross symbol in the program denotes errors
#**Create a class ErrorFree with Errors, debug the code and run it
+
#*Remove semicolon and error details are displayed when mouse is hovered over cross symbol.
#**Eclipse also offers intelligent fixes<br/>  
+
#:<br>
#*Programming features of Eclipse
+
#:'''Fundamental Programming Structures in Java'''
#**Auto completion
+
#Numerical datatypes
#**Sets the corresponding closing brace when we open the brace
+
#*Define datatypes and numerical datatypes
#**Provides a drop-down list of methods when you start typing the code.
+
#*int
#**Syntax highlighting
+
#*float
#**Classname is highlighted in pink color and method in blue color.
+
#*byte
#**Keyboard shortcuts
+
#*short
#**F11 to debug a program and Ctrl plus H to search a specific file.
+
#*long
#**Error highlighting
+
#*double
#**Cross symbol in the program denotes errors
+
#*range of each numerical datatypes
#**Remove semicolon and error details are displayed when mouse is hovered over cross symbol.
+
#*declaration and initializationof numerical datatypes.
#Fundamental Programming Structures in Java
+
#*valid and invalid declaration
#* Numerical datatypes
+
#Arithmetic Operations
#**Define datatypes and numerical datatypes
+
#*Define an operator
#**int
+
#*Define arithmetic operators
#**float
+
#*addition
#**byte
+
#*subtraction
#**short
+
#*multiplication
#**long
+
#*division
#**double
+
#*modulo
#**range of each numerical datatypes
+
#*simple program to demonstrate arithmetic operators
#**declaration and initializationof numerical datatypes.
+
#*appropriate datatypes for appropriate values
#**valid and invalid declaration
+
#*save, compile and run the program<br/>  
#*Arithmetic Operations
+
#Strings
#**Define an operator
+
#*char datatype
#**Define arithmetic operators
+
#*letter, digit, punctuation marks, '''tab''', or a space are all characters.
#**addition
+
#*Program explaining the variable and the character data.
#**subtraction
+
#*Introduction to strings
#**multiplication
+
#*Creating string by Direct Initialization
#**division
+
#*Creating string by using new operator
#**modulo
+
#*String length()
#**simple program to demonstrate arithmetic operators
+
#*String concat()
#**appropriate datatypes for appropriate values
+
#*String toUpperCase()
#**save, compile and run the program<br/>  
+
#*String toLowerCase()<br/>  
#* Strings
+
#Primitive type conversions
#**char datatype
+
#*define type conversion or type casting
#**letter, digit, punctuation marks, '''tab''', or a space are all characters.
+
#*higher order integer to lower order integer- Explicit type casting
#**Program explaining the variable and the character data.
+
#*program to show explicit type casting
#**Introduction to strings
+
#*common mistake in explicit type casting.
#**Creating string by Direct Initialization
+
#*program to show common mistake in explicit type casting
#**Creating string by using new operator
+
#*lower order integer to higher order integer – Implicit type casting
#**String length()
+
#*program to show implicit type casting
#**String concat()
+
#*char to integer
#**String toUpperCase()
+
#*integer to char
#**String toLowerCase()<br/>  
+
#*program to show char to int type casting.
#*Primitive type conversions
+
#:<br>
#**define type conversion or type casting
+
#:'''Control flow'''
#**higher order integer to lower order integer- Explicit type casting
+
#Relational Operations
#**program to show explicit type casting
+
#*boolean datatype
#**common mistake in explicit type casting.
+
#*equal to and not equal to
#**program to show common mistake in explicit type casting
+
#*less than and less than or equal to
#**lower order integer to higher order integer – Implicit type casting
+
#*greater than and greater than or equal to<br/>  
#**program to show implicit type casting
+
#Logical Operations
#**char to integer
+
#*use of logical operators
#**integer to char
+
#*and (&&) operator
#**program to show char to int type casting.
+
#*example to explain '''and''' operator
# Control flow
+
#*program to demonstrate '''and''' operator
#* Relational Operations
+
#*or (||) operator
#**boolean datatype
+
#*example to explain '''or '''operator
#**equal to and not equal to
+
#*program to demonstrate '''or '''operator
#**less than and less than or equal to
+
#*not (!) operator
#**greater than and greater than or equal to<br/>  
+
#*program to demonstrate '''or '''operator
#* Logical Operations
+
#*save, compile and run the programs<br/>  
#**use of logical operators
+
#if else construct
#**and (&&) operator
+
#*Conditional Statements and types of Conditional Statements
#**example to explain '''and''' operator
+
#*Use of if statement
#**program to demonstrate '''and''' operator
+
#*Syntax for if statement
#**or (||) operator
+
#*Program using if statement
#**example to explain '''or '''operator
+
#*Use of if else statement
#**program to demonstrate '''or '''operator
+
#*Syntax for if else statement
#**not (!) operator
+
#*Program using if else statement
#**program to demonstrate '''or '''operator
+
#*Use of if else if statement
#**save, compile and run the programs<br/>  
+
#*Syntax for if else if statement
#*if else construct
+
#*Program using if else if statement<br/>  
#**Conditional Statements and types of Conditional Statements
+
#nested if and ternary operator
#**Use of if statement
+
#*explain nested if
#**Syntax for if statement
+
#*nested if syntax
#**Program using if statement
+
#*program to demonstrate nested if
#**Use of if else statement
+
#*explain the control flow of the program
#**Syntax for if else statement
+
#*explain ternary operator
#**Program using if else statement
+
#*syntax for ternary operator
#**Use of if else if statement
+
#*explain the syntax
#**Syntax for if else if statement
+
#*program to demonstrate ternary operator
#**Program using if else if statement<br/>  
+
#*comparison between ternary operator and nested if
#* nested if and ternary operator
+
#*save, compile and run the program<br/>  
#**explain nested if
+
#switch statement
#**nested if syntax
+
#*define switch case statement
#**program to demonstrate nested if
+
#*compare switch and nested if
#**explain the control flow of the program
+
#*switch case syntax
#**explain ternary operator
+
#*working of a switch case statement
#**syntax for ternary operator
+
#*use of keyword switch
#**explain the syntax
+
#*valid and invalid use of keyword '''case'''
#**program to demonstrate ternary operator
+
#*use of keyword default
#**comparison between ternary operator and nested if
+
#*use of keyword break
#**save, compile and run the program<br/>  
+
#*program to demonstrate switch case statement
#*switch statement
+
#*save, compile and run the program to check the output
#**define switch case statement
+
#while loop
#**compare switch and nested if
+
#*Loop control statement  
#**switch case syntax
+
#*types of loop control statements
#**working of a switch case statement
+
#*Introduction to while loop
#**use of keyword switch
+
#*syntax of while loop
#**valid and invalid use of keyword '''case'''
+
#*Program using while loop
#**use of keyword default
+
#*Check the output.
#**use of keyword break
+
#*Introduction to infinite loop
#**program to demonstrate switch case statement
+
#*loop variable modification
#**save, compile and run the program to check the output
+
#*Check the output
#* while loop
+
#*How to terminate the infinite loop<br/>  
#**Loop control statement  
+
#for loop
#**types of loop control statements
+
#*syntax
#**Introduction to while loop
+
#*introduction to for loop
#**syntax of while loop
+
#*for loop syntax
#**Program using while loop
+
#*loop vaiable
#**Check the output.
+
#*loop condition
#**Introduction to infinite loop
+
#*loop variable increment or decrement
#**loop variable modification
+
#* loop block
#**Check the output
+
#*flow of loop
#**How to terminate the infinite loop<br/>  
+
#*advantage of using loop
#*for loop
+
#do while loop
#**syntax
+
#*define do while  
#**loop continuing condition
+
#*do while syntax
#**loop variable modification<br/>
+
#*working of do while loop
#*do while loop
+
#*example of do while loop
#**define do while  
+
#*explain the do while programming
#**do while syntax
+
#*save, compile and run the program to check the output  
#**working of do while loop
+
#*how different is it from the while loop
#**example of do while loop
+
#*program to demonstrate the differences
#**explain the do while programming
+
#:<br>
#**save, compile and run the program to check the output  
+
#:'''Arrays'''
#**how different is it from the while loop
+
#Introduction to Arrays
#**program to demonstrate the differences
+
#*About Arrays
#Arrays  
+
#*Declare an Array
#*Introduction to Arrays
+
#*Initialize an array
#**What are arrays
+
#*Intilalization using for loop
#**Types of arrays
+
#*Index of an array elements
#**How to create arrays
+
#*change values of an array
#*Array operations
+
#*print the value of an array
#**Accessing array items
+
#*Advantage of an array.
#**Checking for bounds
+
#Array operations
#Classes & Objects  
+
#*import java.util.Arrays
#*Creating class  
+
#*use methods from class Arrays
#**Whatever we can see in this world are all objects
+
#*toString() method
#**Objects can be categorized into groups known as class
+
#*sort() method
#**This is class in real world
+
#*fill() method
#**Human Being is an example of class in real world
+
#*copyof() method
#**Class in java is the blue print from which individual objects are created
+
#*copyofRange() method
#**Class consists defines a set of properties called variables and a set of behaviors called methods
+
#*about parameters for each method.
#**Syntax for creating class
+
#:'''Classes & Objects''' 
#**Create a simple class Student using Eclipse
+
#Creating class  
#**The Student class can contain properties<br/>  
+
#*Whatever we can see in this world are all objects
#*Creating Object
+
#*Objects can be categorized into groups known as class
#**An object is an instance of a class
+
#*This is class in real world
#**Each object consist of state and behavior
+
#*Human Being is an example of class in real world
#**Object stores it state in fields or variables
+
#*Class in java is the blue print from which individual objects are created
#**It exposes its behavior through methods
+
#*Class consists defines a set of properties called variables and a set of behaviors called methods
#**Reference variables
+
#*Syntax for creating class
#**Create a class named TestStudent
+
#*Create a simple class Student using Eclipse
#**Create an object of the Student class
+
#*The Student class can contain properties<br/>  
#**Use new operator
+
#Creating Object
#**Check what the reference variable contains
+
#*An object is an instance of a class
#**Create one more object of the Student class and check what the reference variable contains
+
#*Each object consist of state and behavior
#*Instance fields
+
#*Object stores it state in fields or variables
#**Also known as non-static fields
+
#*It exposes its behavior through methods
#**Open the TestStudent class which we have created
+
#*Reference variables
#**Access the fields roll_number and name using dot operator
+
#*Create a class named TestStudent
#**See the output
+
#*Create an object of the Student class
#**Initialize the field and see the output
+
#*Use new operator
#**Change the modifier of the fields to private
+
#*Check what the reference variable contains
#**Debug the error that you get
+
#*Create one more object of the Student class and check what the reference variable contains
#**Change the modifier to protected
+
#Instance fields
#**Each object of a class will have unique values
+
#*Also known as non-static fields
#**Create two objects of the Student class  
+
#*Open the TestStudent class which we have created
#*Methods
+
#*Access the fields roll_number and name using dot operator
#**method definition  
+
#*See the output
#**write simple method
+
#*Initialize the field and see the output
#**method returning value
+
#*Change the modifier of the fields to private
#**call a method in another method
+
#*Debug the error that you get
#**flow of the program
+
#*Change the modifier to protected
#**call a static method
+
#*Each object of a class will have unique values
#**call a method from another class
+
#*Create two objects of the Student class  
#**method signature
+
#Methods
#**method body  
+
#*method definition  
#Constructors
+
#*write simple method
#*Default constructor
+
#*method returning value
#**what is a constructor?
+
#*call a method in another method
#**what is a default constructor?
+
#*flow of the program
#**when is it called?
+
#*call a static method
#**define a constructor
+
#*call a method from another class
#**initialize the variables
+
#*method signature
#**call the constructor
+
#*method body  
#**difference between constructor and method<br/>  
+
#:<br>
#*Parameterized constructors
+
#:'''Constructors'''
#**What is a parameterized constructor?
+
#Default constructor
#**create constructor without parameter
+
#*what is a constructor?
#**create a constructor with parameter
+
#*what is a default constructor?
#**assign values to the variables in the constructor
+
#*when is it called?
#**pass arguments during the constructor call
+
#*define a constructor
#**working of parameterized constructor
+
#*initialize the variables
#**show common errors
+
#*call the constructor
#**resolve the errors
+
#*difference between constructor and method<br/>  
#**create another parameterized constructor
+
#Parameterized constructors
#**why to use constructor?
+
#*What is a parameterized constructor?
#*Using this keyword
+
#*create constructor without parameter
#**this is a reference to the current object
+
#*create a constructor with parameter
#**helps to avoid name conflicts
+
#*assign values to the variables in the constructor
#**we can use this keyword inside a constructor to call another one
+
#*pass arguments during the constructor call
#**the constructors must be in the same class
+
#*working of parameterized constructor
#**explicit constructor invocation
+
#*show common errors
#**Explain it using the parameterized constructor code
+
#*resolve the errors
#**Make this statement the last one in the constructor
+
#*create another parameterized constructor
#**You will get an error
+
#*why to use constructor?
#**this statement should be the first one inside a constructor
+
#Using this keyword
#*Non-static block
+
#*this is a reference to the current object
#**Non-static block  
+
#*helps to avoid name conflicts
#**Any code written between two curly brackets  
+
#*we can use this keyword inside a constructor to call another one
#**Executed for each object that is created  
+
#*the constructors must be in the same class
#**Executes before constructor's execution  
+
#*explicit constructor invocation
#**can initialize instance member variables of the class  
+
#*Explain it using the parameterized constructor code
#**create a class named NonStaticTest  
+
#*Make this statement the last one in the constructor
#**Create a non-static block and a constructor inside it  
+
#*You will get an error
#**Check the output  
+
#*this statement should be the first one inside a constructor
#**Include multiple non-static blocks  
+
#Non-static block
#**they will be executed in the sequence in which they appear in the class  
+
#*Non-static block  
#**Check the output  
+
#*Any code written between two curly brackets  
#**Non-static block is not a substitute for constructor
+
#*Executed for each object that is created  
#*Constructor Overloading
+
#*Executes before constructor's execution  
#**define multiple constructor
+
#*can initialize instance member variables of the class  
#**what is constructor overloading?
+
#*create a class named NonStaticTest  
#**constructor with different number of parameters.
+
#*Create a non-static block and a constructor inside it  
#**parameters with different datatypes.
+
#*Check the output  
#**how is constructor overloaded?
+
#*Include multiple non-static blocks  
#**flow of overloading process.
+
#*they will be executed in the sequence in which they appear in the class  
#**advantage of constructor overloading.
+
#*Check the output  
#*Method Overloading
+
#*Non-static block is not a substitute for constructor
#**define multiple methods.
+
#Constructor Overloading
#**methods with same name.
+
#*define multiple constructor
#**methods with different number of parameters.
+
#*what is constructor overloading?
#**methods with different datatypes of parameter.
+
#*constructor with different number of parameters.
#**what is method overloading?
+
#*parameters with different datatypes.
#**example for overloadin method
+
#*how is constructor overloaded?
#**how to overload method?
+
#*flow of overloading process.
#**advantage of method overloading.
+
#*advantage of constructor overloading.
#**error in method overloading.
+
#Method Overloading
 +
#*define multiple methods.
 +
#*methods with same name.
 +
#*methods with different number of parameters.
 +
#*methods with different datatypes of parameter.
 +
#*what is method overloading?
 +
#*example for overloadin method
 +
#*how to overload method?
 +
#*advantage of method overloading.
 +
#*error in method overloading.
 +
#Taking user input in Java
 +
#*What is BufferedReader?
 +
#*Importing three classes from Java.io package
 +
#*How to take the input from the user?
 +
#*Syntax to implement BufferedReader
 +
#*What is InputStreamReader?
 +
#*Create object of InputStreamReader
 +
#*Create object of BufferedReader
 +
#*About IOException
 +
#*About throws keyword
 +
#*Typecasting
  
 
== Intermediate Level ==
 
== Intermediate Level ==
 
+
#Subclassing and Method Overriding
== Advanced Level ==
+
#*Definition of subclassing
 +
#*Demo of subclassing using an Employee and Manager class
 +
#*Single inheritance
 +
#*Use of extends keyword
 +
#*Private members in a super class
 +
#*Definition of method overriding
 +
#*Annotation
 +
#*@Override Annotation
 +
#Calling methods of the superclass
 +
#*super keyword
 +
#*Call methods of the super class
 +
#*Constructor of the super class
 +
#*Demo of super keyword using an Employee and Manager class
 +
#*Single inheritance
 +
#*Use of extends keyword
 +
#*Private members in a super class
 +
#Using final keyboard
 +
#*final keyword
 +
#*What is final keyword and its application?
 +
#*Where final keyword can be declared?
 +
#*final variable
 +
#*final static variables
 +
#*static block
 +
#*final variable as parameter
 +
#*final method
 +
#*private final method
 +
#*final class
 +
#Polymorphism
 +
#*Polymorphism in Java
 +
#*Run-time polymorphism
 +
#*Virtual Method Invocation
 +
#*Compile-time polymorphism
 +
#*Role of JVM
 +
#*IS-A test
 +
#*Static binding
 +
#*Dynamic binding
 +
#Abstract Classes
 +
#*Abstract Classes in Java
 +
#*What  are Abstract Methods
 +
#*What are Concrete Methods
 +
#*Properties of Abstract Methods and Abstract Classes
 +
#*How to use Abstract Methods
 +
#Java Interfaces
 +
#*Java Interfaces
 +
#*Implementing Interface
 +
#*Implementation Classes
 +
#*Interfaces Vs Abstract classes
 +
#*Implementing Multiple Interfaces
 +
#*Usage of Interfaces with an example
 +
#Static Variables
 +
#*What is Static Variable in Java?
 +
#*Usage of Static Variables with Example
 +
#*Static Variables Vs Instance Variables
 +
#*Final Static Constants
 +
#Static Methods
 +
#*What is static method in Java?
 +
#*Static methods Vs Instance methods
 +
#*Usage of static method with example
 +
#*Passing object variables in a static method
 +
#Static Blocks
 +
#*What is a static block
 +
#*Declaring and defining a static block
 +
#*How static blocks are invoked and executed

Revision as of 08:35, 26 March 2018

Introduction

Welcome to online web tutorials for java
Java[ http://java.sun.com ]is a free and open source high level programming language. It is simple as well as object oriented language. Till date, the Java platform has attracted more than 6.5 million software developers. Java Platform, Standard Edition (Java SE) lets you develop and deploy Java applications on desktops and servers, as well as today's demanding Embedded and Real-Time environments.From laptops to mobile phones, game consoles to scientific supercomputers, music players to the Internet,Set-top boxes to printers, Web cams to medical devices,Ooops that is a huge list to follow,Java is everywhere!!!!!

This set of tutorials will cover features and usage of Java version 1.6.x Please see the associated text box of individual spoken tutorials on the website to decide the versions of Java and OS to which it is applicable.

The Spoken Tutorial Effort for Java is contributed jointly by TalentSprint, Hyderabad and the Spoken Tutorial Team, IIT Bombay. Other contributors who helped in the creation of the scripts are ............

Glossary

Basic Level

Introduction to Java
  1. Getting started with Java – installation
    • Install jdk from Synaptic Package Manager
    • Choose openjdk-6-jdk from the list of packages available
    • Mark it for installation
    • The installation will take a few seconds
    • Verify the installation
    • At the command prompt type java -version, so the version number of the jdk will be displayed
    • Run a simple java program and see if it works
    • Type javac TestProgram.java for compiling the code and java TestProgram for executing the code
  2. Java - First program
    • write simple java program
    • print “My First Java Program!” on Console
    • save the file
    • file name given to the java file
    • compile the file
    • run the file
    • correct the errors
    • naming conventions for class
    • naming conventions for method
    • naming conventions for variable

    Eclipse
  3. Installing Eclipse
    • Install Eclipse on Ubuntu on the Terminal
    • Set up the proxy on the Terminal
    • Then fetch the list of all the available softwares
    • Type sudo apt-get update
    • Then install eclipse on the Terminal
    • Type sudo apt-get install eclipse
    • Verify if Eclipse is installed on the system
    • Installing Eclipse on Debian,Kubuntu,Xubuntu
    • Installing Eclipse on Redhat
    • Installing Eclipse on Fedora,centos and suse linux
  4. Getting started with Eclipse
    • Eclipse is an Integrated Development Environment
    • It is a tool on which one can write, debug and run java programs easily
    • Open Dash Home and type Eclipse in the search box.
    • We get Workspace Launcher
    • On clicking on Workbench we get the Eclipse IDE
    • Go to File->New->Project and select Java Project
    • Create a project named EclipseDemo and create a class inside DemoClass
    • Learn about Package Explorer and Editor portlet
  5. Hello World Program
    • Open Eclipse
    • Create a Java Project named DemoProject
    • Create a class named DemoClass
    • Class name and file name will be the same
    • Eclipse suggests various possibilities as we type a command
    • Eclipse also completes the parentheses by automatically adding the closing parentheses
    • Include the statement that we want to print
    • Eclipse also completes the quotes by adding the closing quote
    • Compile and execute the program
    • Change the code to print
  6. Errors and Debugging
    • When writing a Java Program, here is a list of typical errors:
    • Missing semicolon(;)
    • Missing double quotes(".")
    • Mis-match of filename and classname
    • Typing the print statement n lower case
    • The line which has the error will be indicated with a red cross mark on the left margin
    • The list of errors is displayed by hovering the mouse over the cross mark
    • Create a class ErrorFree with Errors, debug the code and run it
    • Eclipse also offers intelligent fixes
  7. Programming features of Eclipse
    • Auto completion
    • Sets the corresponding closing brace when we open the brace
    • Provides a drop-down list of methods when you start typing the code.
    • Syntax highlighting
    • Classname is highlighted in pink color and method in blue color.
    • Keyboard shortcuts
    • F11 to debug a program and Ctrl plus H to search a specific file.
    • Error highlighting
    • Cross symbol in the program denotes errors
    • Remove semicolon and error details are displayed when mouse is hovered over cross symbol.

    Fundamental Programming Structures in Java
  8. Numerical datatypes
    • Define datatypes and numerical datatypes
    • int
    • float
    • byte
    • short
    • long
    • double
    • range of each numerical datatypes
    • declaration and initializationof numerical datatypes.
    • valid and invalid declaration
  9. Arithmetic Operations
    • Define an operator
    • Define arithmetic operators
    • addition
    • subtraction
    • multiplication
    • division
    • modulo
    • simple program to demonstrate arithmetic operators
    • appropriate datatypes for appropriate values
    • save, compile and run the program
  10. Strings
    • char datatype
    • letter, digit, punctuation marks, tab, or a space are all characters.
    • Program explaining the variable and the character data.
    • Introduction to strings
    • Creating string by Direct Initialization
    • Creating string by using new operator
    • String length()
    • String concat()
    • String toUpperCase()
    • String toLowerCase()
  11. Primitive type conversions
    • define type conversion or type casting
    • higher order integer to lower order integer- Explicit type casting
    • program to show explicit type casting
    • common mistake in explicit type casting.
    • program to show common mistake in explicit type casting
    • lower order integer to higher order integer – Implicit type casting
    • program to show implicit type casting
    • char to integer
    • integer to char
    • program to show char to int type casting.

    Control flow
  12. Relational Operations
    • boolean datatype
    • equal to and not equal to
    • less than and less than or equal to
    • greater than and greater than or equal to
  13. Logical Operations
    • use of logical operators
    • and (&&) operator
    • example to explain and operator
    • program to demonstrate and operator
    • or (||) operator
    • example to explain or operator
    • program to demonstrate or operator
    • not (!) operator
    • program to demonstrate or operator
    • save, compile and run the programs
  14. if else construct
    • Conditional Statements and types of Conditional Statements
    • Use of if statement
    • Syntax for if statement
    • Program using if statement
    • Use of if else statement
    • Syntax for if else statement
    • Program using if else statement
    • Use of if else if statement
    • Syntax for if else if statement
    • Program using if else if statement
  15. nested if and ternary operator
    • explain nested if
    • nested if syntax
    • program to demonstrate nested if
    • explain the control flow of the program
    • explain ternary operator
    • syntax for ternary operator
    • explain the syntax
    • program to demonstrate ternary operator
    • comparison between ternary operator and nested if
    • save, compile and run the program
  16. switch statement
    • define switch case statement
    • compare switch and nested if
    • switch case syntax
    • working of a switch case statement
    • use of keyword switch
    • valid and invalid use of keyword case
    • use of keyword default
    • use of keyword break
    • program to demonstrate switch case statement
    • save, compile and run the program to check the output
  17. while loop
    • Loop control statement
    • types of loop control statements
    • Introduction to while loop
    • syntax of while loop
    • Program using while loop
    • Check the output.
    • Introduction to infinite loop
    • loop variable modification
    • Check the output
    • How to terminate the infinite loop
  18. for loop
    • syntax
    • introduction to for loop
    • for loop syntax
    • loop vaiable
    • loop condition
    • loop variable increment or decrement
    • loop block
    • flow of loop
    • advantage of using loop
  19. do while loop
    • define do while
    • do while syntax
    • working of do while loop
    • example of do while loop
    • explain the do while programming
    • save, compile and run the program to check the output
    • how different is it from the while loop
    • program to demonstrate the differences

    Arrays
  20. Introduction to Arrays
    • About Arrays
    • Declare an Array
    • Initialize an array
    • Intilalization using for loop
    • Index of an array elements
    • change values of an array
    • print the value of an array
    • Advantage of an array.
  21. Array operations
    • import java.util.Arrays
    • use methods from class Arrays
    • toString() method
    • sort() method
    • fill() method
    • copyof() method
    • copyofRange() method
    • about parameters for each method.
    Classes & Objects
  22. Creating class
    • Whatever we can see in this world are all objects
    • Objects can be categorized into groups known as class
    • This is class in real world
    • Human Being is an example of class in real world
    • Class in java is the blue print from which individual objects are created
    • Class consists defines a set of properties called variables and a set of behaviors called methods
    • Syntax for creating class
    • Create a simple class Student using Eclipse
    • The Student class can contain properties
  23. Creating Object
    • An object is an instance of a class
    • Each object consist of state and behavior
    • Object stores it state in fields or variables
    • It exposes its behavior through methods
    • Reference variables
    • Create a class named TestStudent
    • Create an object of the Student class
    • Use new operator
    • Check what the reference variable contains
    • Create one more object of the Student class and check what the reference variable contains
  24. Instance fields
    • Also known as non-static fields
    • Open the TestStudent class which we have created
    • Access the fields roll_number and name using dot operator
    • See the output
    • Initialize the field and see the output
    • Change the modifier of the fields to private
    • Debug the error that you get
    • Change the modifier to protected
    • Each object of a class will have unique values
    • Create two objects of the Student class
  25. Methods
    • method definition
    • write simple method
    • method returning value
    • call a method in another method
    • flow of the program
    • call a static method
    • call a method from another class
    • method signature
    • method body

    Constructors
  26. Default constructor
    • what is a constructor?
    • what is a default constructor?
    • when is it called?
    • define a constructor
    • initialize the variables
    • call the constructor
    • difference between constructor and method
  27. Parameterized constructors
    • What is a parameterized constructor?
    • create constructor without parameter
    • create a constructor with parameter
    • assign values to the variables in the constructor
    • pass arguments during the constructor call
    • working of parameterized constructor
    • show common errors
    • resolve the errors
    • create another parameterized constructor
    • why to use constructor?
  28. Using this keyword
    • this is a reference to the current object
    • helps to avoid name conflicts
    • we can use this keyword inside a constructor to call another one
    • the constructors must be in the same class
    • explicit constructor invocation
    • Explain it using the parameterized constructor code
    • Make this statement the last one in the constructor
    • You will get an error
    • this statement should be the first one inside a constructor
  29. Non-static block
    • Non-static block
    • Any code written between two curly brackets
    • Executed for each object that is created
    • Executes before constructor's execution
    • can initialize instance member variables of the class
    • create a class named NonStaticTest
    • Create a non-static block and a constructor inside it
    • Check the output
    • Include multiple non-static blocks
    • they will be executed in the sequence in which they appear in the class
    • Check the output
    • Non-static block is not a substitute for constructor
  30. Constructor Overloading
    • define multiple constructor
    • what is constructor overloading?
    • constructor with different number of parameters.
    • parameters with different datatypes.
    • how is constructor overloaded?
    • flow of overloading process.
    • advantage of constructor overloading.
  31. Method Overloading
    • define multiple methods.
    • methods with same name.
    • methods with different number of parameters.
    • methods with different datatypes of parameter.
    • what is method overloading?
    • example for overloadin method
    • how to overload method?
    • advantage of method overloading.
    • error in method overloading.
  32. Taking user input in Java
    • What is BufferedReader?
    • Importing three classes from Java.io package
    • How to take the input from the user?
    • Syntax to implement BufferedReader
    • What is InputStreamReader?
    • Create object of InputStreamReader
    • Create object of BufferedReader
    • About IOException
    • About throws keyword
    • Typecasting

Intermediate Level

  1. Subclassing and Method Overriding
    • Definition of subclassing
    • Demo of subclassing using an Employee and Manager class
    • Single inheritance
    • Use of extends keyword
    • Private members in a super class
    • Definition of method overriding
    • Annotation
    • @Override Annotation
  2. Calling methods of the superclass
    • super keyword
    • Call methods of the super class
    • Constructor of the super class
    • Demo of super keyword using an Employee and Manager class
    • Single inheritance
    • Use of extends keyword
    • Private members in a super class
  3. Using final keyboard
    • final keyword
    • What is final keyword and its application?
    • Where final keyword can be declared?
    • final variable
    • final static variables
    • static block
    • final variable as parameter
    • final method
    • private final method
    • final class
  4. Polymorphism
    • Polymorphism in Java
    • Run-time polymorphism
    • Virtual Method Invocation
    • Compile-time polymorphism
    • Role of JVM
    • IS-A test
    • Static binding
    • Dynamic binding
  5. Abstract Classes
    • Abstract Classes in Java
    • What are Abstract Methods
    • What are Concrete Methods
    • Properties of Abstract Methods and Abstract Classes
    • How to use Abstract Methods
  6. Java Interfaces
    • Java Interfaces
    • Implementing Interface
    • Implementation Classes
    • Interfaces Vs Abstract classes
    • Implementing Multiple Interfaces
    • Usage of Interfaces with an example
  7. Static Variables
    • What is Static Variable in Java?
    • Usage of Static Variables with Example
    • Static Variables Vs Instance Variables
    • Final Static Constants
  8. Static Methods
    • What is static method in Java?
    • Static methods Vs Instance methods
    • Usage of static method with example
    • Passing object variables in a static method
  9. Static Blocks
    • What is a static block
    • Declaring and defining a static block
    • How static blocks are invoked and executed

Contributors and Content Editors

Arya Ratish, Minal, Nancyvarkey, PoojaMoolya, Pratham920, Pratik kamble, Priyacst