Difference between revisions of "Java"

From Script | Spoken-Tutorial
Jump to: navigation, search
(Created page with '=Introduction= '''Welcome to online web tutorials for java'''<br> Java[ http://java.sun.com ]is a free and open source high level programming language. It is simple as well as ob…')
 
(Intermediate Level)
 
(40 intermediate revisions by 6 users not shown)
Line 5: Line 5:
 
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.  
 
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 ............  
+
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 Prathamesh Salunke, Arya Ratish, Ashwini Patil.
 +
 
 +
'''Learners''':  UG/PG CSE/IT/CS students.
  
 
<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 16: Line 17:
 
== Basic Level==
 
== Basic Level==
  
1. Installing the JDK & compiling HelloWorld program in Java
+
:'''Introduction to Java'''
 
+
#Getting started with Java – installation
  * Importance of java
+
#* Install jdk from Synaptic Package Manager
  * Installing the JDK using Synaptic Package Manager on Ubuntu
+
#* Choose openjdk-6-jdk from the list of packages available
  * Creating a source file in Text Editor
+
#*Mark it for installation
  * Creating a class HelloWorld
+
#*The installation will take a few seconds
  * Saving the file with the same name as the class i.e. HelloWorld with .java extension
+
#*Verify the installation
  * Compiling file using javac compiler, to create a .class file
+
#*At the command prompt type java -version, so the version number of the jdk will be displayed
  * Running the program
+
#*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
 
+
#Java - First program
2. Accessing the variables and methods in Java
+
#*write simple java program
 
+
#*print “My First Java Program!” on Console
  * Creating Student.java file in the Text Editor
+
#*save the file
  * Declaring the class Student
+
#*file name given to the java file
  * Datatypes used - int, float, String
+
#*compile the file
  * Declaring the variables Name,RollNo,Percentage
+
#*run the file
  * Declaring and defining the methods getRollNo() and setRollNo() (The getter and setter methods).
+
#*correct the errors
  * Creating an instance of the class i.e. object using new operator.
+
#*naming conventions for class
  * Accessing variables and method using dot operator.  
+
#*naming conventions for method
  * Saving the file
+
#*naming conventions for variable
  * Compiling using the command javac Student.java in the terminal.
+
#:<br>
  * Running the program using command java Student and checking the output.
+
#:'''Eclipse'''
 
+
#Installing Eclipse
3. Use of Static
+
#*Install Eclipse on Ubuntu on the Terminal
 
+
#*Set up the proxy on the Terminal
  class static1
+
#*Then fetch the list of all the available softwares
  {
+
#*Type sudo apt-get update
  static int b=10;
+
#*Then install eclipse on the Terminal
  public static int show(int a)
+
#*Type sudo apt-get install eclipse
  {
+
#*Verify if Eclipse is installed on the system
      return a;
+
#*Installing Eclipse on Debian,Kubuntu,Xubuntu
  }
+
#*Installing Eclipse on Redhat
  public static void main(String arg[])
+
#*Installing Eclipse on Fedora,centos and suse linux
  {
+
#Getting started with Eclipse
      // static1 s=new static1();
+
#*Eclipse is an Integrated Development Environment
      System.out.println(show(b));
+
#*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
4. The if Instruction Control Statements in Java
+
#*Learn about Package Explorer and Editor portlet
+
#Hello World Program
  * if Statement
+
#*Open Eclipse
  * if-else Statement
+
#*Create a Java Project named DemoProject
    if(Boolean_expression)//Statement executes when the Boolean expression is true
+
#*Create a class named DemoClass
    else
+
#*Class name and file name will be the same
  //Statement executes when the Boolean expression is false
+
#*Eclipse suggests various possibilities as we type a command
    Example - if(String  password=="pratham"){System.out.print("login");}
+
#*Eclipse also completes the parentheses by automatically adding the closing parentheses
              else
+
#*Include the statement that we want to print
              {  System.out.println("access denied");
+
#*Eclipse also completes the quotes by adding the closing quote
              }
+
#*Compile and execute the program
  * Nested if's- one if statement inside another if statement
+
#*Change the code to print<br/>
 
+
#Errors and Debugging
5. The switch Instruction control statement in Java
+
#*When writing a Java Program, here is a list of typical errors:
  * switch(expression)
+
#*Missing semicolon(;)
    case value :
+
#*Missing double quotes(".")
    //Statements
+
#*Mis-match of filename and classname
    break; //optional
+
#*Typing the print statement n lower case
    //You can have any number of case statements.
+
#*The line which has the error will be indicated with a red cross mark on the left margin
    default : //Optional
+
#*The list of errors is displayed by hovering the mouse over the cross mark
    //Statements
+
#*Create a class ErrorFree with Errors, debug the code and run it
    Example -    int select=1;
+
#*Eclipse also offers intelligent fixes<br/>
                  switch(select)  {
+
#Programming features of Eclipse
                  case 0: System.out.println("Number is zero");
+
#*Auto completion
                  break;
+
#*Sets the corresponding closing brace when we open the brace
                  case 1: System.out.println("Number is one");
+
#*Provides a drop-down list of methods when you start typing the code.
                  break;
+
#*Syntax highlighting
                  default:
+
#*Classname is highlighted in pink color and method in blue color.
                  System.out.println("Invalid Entry!");
+
#*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
6. The while and do-while Decision Control loops in Java
+
#*Remove semicolon and error details are displayed when mouse is hovered over cross symbol.
* while loop
+
#:<br>
  while(Boolean_expression true)// execute statements
+
#:'''Fundamental Programming Structures in Java'''
  Example  -  int a=0;
+
#Numerical datatypes
                while(a<10) {
+
#*Define datatypes and numerical datatypes
                System.out.println("Number is "+a);
+
#*int
                a++;
+
#*float
                }
+
#*byte
* do...while loop
+
#*short
  do {  //Statements } while(Boolean_expression);
+
#*long
  Example  -    do  {
+
#*double
                      System.out.println("Number is "+a);a++;
+
#*range of each numerical datatypes
                      }
+
#*declaration and initializationof numerical datatypes.
                while(a<10);
+
#*valid and invalid declaration
 
+
#Arithmetic Operations
7. The for Decision Control loop in Java
+
#*Define an operator
  *for(initialization; condition; increment/decrement)//execute statements
+
#*Define arithmetic operators
  Example -  for(int a=0;a<10;a++)  {
+
#*addition
                System.out.println("Number is "+a);
+
#*subtraction
                }
+
#*multiplication
 
+
#*division
 
+
#*modulo
8. Providing constructors for the class
+
#*simple program to demonstrate arithmetic operators
+
#*appropriate datatypes for appropriate values
* Creating a class rectangle in the Text Editor.
+
#*save, compile and run the program<br/>
* Creating a constructor rectangle(int a,int b){x=a;y=b;} with two parameters.
+
#Strings
* Initializing the variables in the constructor
+
#*char datatype
* Declaring a method area(){return(x*y);}
+
#*letter, digit, punctuation marks, '''tab''', or a space are all characters.
* Invoking the constructor and method.
+
#*Program explaining the variable and the character data.
* Saving, compiling and executing the program and checking the output.
+
#*Introduction to strings
 
+
#*Creating string by Direct Initialization
 
+
#*Creating string by using new operator
9. Single dimensional arrays in java
+
#*String length()
 
+
#*String concat()
* Declaring an array    - int num[];
+
#*String toUpperCase()
* Defining an array   
+
#*String toLowerCase()<br/>
  Example - int num = new int[2];
+
#Primitive type conversions
* Initializing an array
+
#*define type conversion or type casting
  Example - int num[0]=45;
+
#*higher order integer to lower order integer- Explicit type casting
* Anonymous arrays     
+
#*program to show explicit type casting
  Example - int array1[] = {1, 2, 3, 4, 5};
+
#*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
10. Multi-dimensional arrays in Java
+
#*program to show implicit type casting
+
#*char to integer
* Declaring an array      - int TwoArray[ ][ ];
+
#*integer to char
* Defining an array       
+
#*program to show char to int type casting.
  Example - int TwoArray[ ][ ]  = new int [7 ][12 ];
+
#:<br>
* Initializing an array 
+
#:'''Control flow'''
  Example - int TwoArray[ 0][0 ]  =72;
+
#Relational Operations
* Ragged arrays           
+
#*boolean datatype
  Example - int[][] array = {{0,1,2,3,4},
+
#*equal to and not equal to
                              {0,1,2},
+
#*less than and less than or equal to
                              {0},
+
#*greater than and greater than or equal to<br/>
                              {0,1,}};
+
#Logical Operations
 
+
#*use of logical operators
 
+
#*and (&&) operator
11. Exception Handling in Java
+
#*example to explain '''and''' operator
+
#*program to demonstrate '''and''' operator
* try{}catch(Exception e){error message}
+
#*or (||) operator
* Example- try  {
+
#*example to explain '''or '''operator
                  int c =8/0;
+
#*program to demonstrate '''or '''operator
                }
+
#*not (!) operator
            catch(Exception e)  {
+
#*program to demonstrate '''or '''operator
                  System.out.print("Error: Division by zero");
+
#*save, compile and run the programs<br/>
                  }
+
#if else construct
 
+
#*Conditional Statements and types of Conditional Statements
12. Command Line Arguments
+
#*Use of if statement
 
+
#*Syntax for if statement
* Arguments given at run time.
+
#*Program using if statement
* Arguments are assigned to String array.
+
#*Use of if else statement
* This String array is the parameter of the main function.
+
#*Syntax for if else statement
  public static void main(String arg[])
+
#*Program using if else statement
  {
+
#*Use of if else if statement
    System.out.println("hello "+arg[0]);
+
#*Syntax for if else if statement
  }
+
#*Program using if else if statement<br/>
+
#nested if and ternary operator
 
+
#*explain nested if
13. Method parameters.
+
#*nested if syntax
+
#*program to demonstrate nested if
* Pass by reference
+
#*explain the control flow of the program
* Pass by value
+
#*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<br/>
 +
#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
 +
#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<br/>
 +
#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
 +
#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
 +
#:<br>
 +
#:'''Arrays'''
 +
#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.
 +
#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'''  
 +
#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<br/>
 +
#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
 +
#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
 +
#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
 +
#:<br>
 +
#:'''Constructors'''
 +
#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<br/>
 +
#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?
 +
#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
 +
#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
 +
#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.
 +
#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
 +
#Exception Handling
 +
#*What is an Exception
 +
#*Types of Exceptions
 +
##Checked Exceptions
 +
##Unchecked Exceptions
 +
#*Explaining ''ArrayIndexOutOfBoundsException''
 +
#*Demonstrating Checked Exceptions with example
 +
#*Handling Exceptions using try-catch blocks
 +
#*Explaining ''ArithmeticException''
 +
#*Demonstrating Unchecked Exceptions with example
 +
#*Explaining ''FileNotFoundException''
 +
#*Usage of finally block
 +
#*Explaining ''NullPointerException''
 +
#Custom Exceptions
 +
#*What is a Custom Exception
 +
#*Demonstration of custom exception
 +
#*Custom exception example - "InvalidMarkException"
 +
#*Usage of "throw" keyword
 +
#*How to resolve errors in custom exceptions
 +
#*Resolve error using "Add throws declaration" option
 +
#*Usage of "throws" keyword
 +
#*Example for "FileNotFoundException"
 +
#*How to handle multiple exceptions
 +
#*How to use "surround with try/catch" option

Latest revision as of 15:33, 9 October 2020

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 Prathamesh Salunke, Arya Ratish, Ashwini Patil.

Learners: UG/PG CSE/IT/CS students.

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
  10. Exception Handling
    • What is an Exception
    • Types of Exceptions
    1. Checked Exceptions
    2. Unchecked Exceptions
    • Explaining ArrayIndexOutOfBoundsException
    • Demonstrating Checked Exceptions with example
    • Handling Exceptions using try-catch blocks
    • Explaining ArithmeticException
    • Demonstrating Unchecked Exceptions with example
    • Explaining FileNotFoundException
    • Usage of finally block
    • Explaining NullPointerException
  11. Custom Exceptions
    • What is a Custom Exception
    • Demonstration of custom exception
    • Custom exception example - "InvalidMarkException"
    • Usage of "throw" keyword
    • How to resolve errors in custom exceptions
    • Resolve error using "Add throws declaration" option
    • Usage of "throws" keyword
    • Example for "FileNotFoundException"
    • How to handle multiple exceptions
    • How to use "surround with try/catch" option

Contributors and Content Editors

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