java training in ahmedabad - PowerPoint PPT Presentation

About This Presentation
Title:

java training in ahmedabad

Description:

Learn to develop Android application from experienced professionals. Vaayaa Edu provides professional software training with the help of working industry professionals in the field of PHP, ASP.Net with C#, seo, android, java and Web designing courses and over 42 courses with assured JOB opportunity in ahmedabad. – PowerPoint PPT presentation

Number of Views:129

less

Transcript and Presenter's Notes

Title: java training in ahmedabad


1
Decision Making and Branching
  • Created By Bhoomi Shah
  • Java and Advanced Java Trainer At VaaYaa Education

2
Conditional Statements
  • IF
  • IF Else
  • Else If
  • Switch
  • IF
  • Syntax if(condition)
  • Statements
  • Example If(no1gtno2)
  • Printf (Number 1 is big)

3
Continue....
  • If else
  • Syntax
  • If(Condition)
  • Statement
  • Else
  • statement

4
Example
  • If(no1gtno2)
  • printf(No1 is big)
  • Else
  • printf(No2 is small)

5
Else If
  • If(condition 1)
  • Statement1
  • Elseif(condition 2)
  • Statement2
  • Elseif(condition 3)
  • Statement3
  • Elseif(condition 4)
  • Statement4
  • Else
  • Statement 5

6
Example
  • If(code1)
  • colourred
  • Else if(code2)
  • Colour blue
  • Else if(code3)
  • Colouryellow
  • Else
  • Colourwhite

7
Switch Statement
  • Syntax
  • Switch(expression)
  • Case value
  • statement break
  • Case value
  • statementbreak
  • Case value
  • statement break
  • Default
  • statement break

8
Example
  • switch (grade)
  • case 1 printf("Fall (F)\n")breakcase 2
    printf("Bad (D)\n")breakcase 3 printf("Good
    (C)\n")breakcase 4 printf("Very Good
    (B)\n")breakcase 5 printf("Excellent
    (A)\n")breakdefaultprintf("You have inputted
    false grade\n")break // break isnt necessary
    here

9
Decision Making and Looping
10
Loops
  • Loops are used to repeat a block of code.
  • A looping process ,in general, would include yhe
    folloinf four steps
  • 1) Setting and initialization of a counter
  • 2) Execution of the statement in the loop
  • 3) Test for a specified condition for execution
    of the loop
  • 4) Incrementing the counter

11
Types of Loops
  • Java supports three types of loops
  • For loop
  • While loop
  • Do While loop

12
For loop
  • For Loop
  • Syntax for(initializationconditionincreament)
  • Example for(i1ilt10i)

13
Example
  • Class abc
  • public static void main(String args)
  • int x
  • for ( x 0 x lt 10 x )
  • System.out.println(x x)

14
While Loop
  • While Loop Code to execute while the condition
    is true
  • Syntax
  • While(test condition)
  • body of the loop
  • Example
  • While(igt10)
  • System.out.println( I i)
  • i

15
Example
  • -------
  • -------
  • Sum o
  • N1
  • While(n lt 10)
  • SumSumnn
  • nn1
  • System.out.println(Sum sum)

16
Do while Loop
  • Syntax
  • do
  • while ( condition )
  • Example
  • Class abc
  • public static void main(args)
  • int x
  • x 0
  • do
  • System.out.println( "Hello, world!\n" )
  • while ( x ! 0 )

17
Classes,ObjectsMethods
18
Classes
  • A class os a userdefind data type with a template
    that serves to define its properties.
  • Once the class has been defined,,we have create a
    nuer of objects
  • The basic form of a class defition is
  • Class classname extends superclassname
  • field declaration
  • method declaration

19
Fields Declaration
  • Data is encapsulated in a class by placing data
    fields inside the body of the class defition.
  • We can declare the instabce variable exctly the
    same way as we declare local variables
  • Example
  • class rectangle
  • int length
  • int width

20
Method Declaration
  • A class with only data fields has no
    life.
  • We must add methods that are necessary
    for manipulating the data contained in
    the class.
  • Methods are declared inside the body of
    the class but immediately after the
    declaration of variable.

21
Continue
  • The general form of a method declaration is
  • type methodname (parameter-list)
  • method-body

22
Continue
  • Method declaration have four basic parts
  • 1)The name of the method (methodname)
  • 2)The type of the value the method return(type)
  • 3)A list of parameters(paramter-list)
  • 4)The body of the method

23
Example
  • class rectangle
  • int length
  • int width
  • Void getdata(int x, int y) // method
    declaration
  • lengthx
  • lengthy

24
Creating Object
  • Object in java are created using the new
    operator.
  • The new operator creates an object of the
    specified class and returns a reference to that
    object.
  • Example
  • Rectangle rect1 //declare the
    object
  • rect1 new Rectangle() //instantiate object
  • Second way to create a object
  • Rectangle rect1new Rectangle()
  • Rectangle rect2new Rectangle()
  • and so on..

25
Accessing Class Member
  • Syntax for assigning the value
  • objectname.variablenamevalue
  • objectname.methodname(parameter-list)
  • Example
  • rect1.length15
  • rect1.width20
  • rect2.length22
  • rect2.width28

26
Example
  • Class Rectangle
  • int length,width //declaration of variable
  • void getData(int x, int y) //defition og methods
  • lengthx
  • widthy
  • int arealengthwidth //definition of
    another method
  • return(area)

27
Countiue
  • rect2.getData(20,12) //accessing methods
  • area2rect2.rectArea()
  • System.out.println(Area1 area1)
  • System.out.println(Area2 area2)

28
Thank You
  • VaaYaa Edutech provides Java and Advanced
    Training in Ahmedabad.
  • A/1/A, 3rd Floor, VaaYaa Lobby, Chinubhai Tower,
    Next to H K College, Ashram Road, Income Tax,
    Gujarat, Ahmedabad- 380009
  • Call Us Now 919586979730
  • vaayaaedu_at_gmail.com
  • Website http//www.vaayaaedu.com/
Write a Comment
User Comments (0)
About PowerShow.com