Что такое findslide.org?

FindSlide.org - это сайт презентаций, докладов, шаблонов в формате PowerPoint.


Для правообладателей

Обратная связь

Email: Нажмите что бы посмотреть 

Яндекс.Метрика

Презентация на тему Classes and objects

Classes and Objects public class Box{int length;int width; Void calculateArea(){ int area=length*width;System.out.println(“Area is” +area); }}public class TestBox{public static void main (String[] args){Box obj1 =new Box();Box obj2 =new Box();obj1.length=5;obj1.width=10;obj1.calculateArea;obj2.length=15;obj2.width=2;obj2.calculateArea;}}
Classes and Objects public class Employee{double salary;double bonus; Void calculateTotalPay(){ double totalpay=salary+bonus;System.out.println(“Totalpay is” +totalpay); }}Object Classes and Objects public class Box{int length;int width; Void calculateArea(){ int area=length*width;System.out.println(“Area is” +area); }}public Advantage of return method calculating sum of areas public class Box{int length;int Methods with arguments public class Box{int length;int width; Int calculateArea(int x){ int area=length*width*x;return area; }}public Methods with arguments public class Box{int length;int width; Int calculateArea(int length,int width){ int area=length*width;return Methods with arguments public class Box{int length;int width; Int calculateArea( int length,int width){ int Constructors public class SmallBox{int length;int width; SmallBox(int length, int width) {this.length = length;this.width=width;}void if you want some defalt value you can use a constructor(initial defalt if you want some defalt value you can use a constructor(initial defalt
Слайды презентации

Слайд 2 Classes and Objects
public class Box{
int length;
int width;
 
Void calculateArea(){
 
int

Classes and Objects public class Box{int length;int width; Void calculateArea(){ int area=length*width;System.out.println(“Area is”

area=length*width;
System.out.println(“Area is” +area);
 
}
}

public class TestBox{
public static void main (String[]

args){
Box obj1 =new Box();
Box obj2 =new Box();
obj1.length=5;
obj1.width=10;
obj1.calculateArea;
obj2.length=15;
obj2.width=2;
obj2.calculateArea;
}
}




Слайд 3 Advantage of return method calculating sum of areas
public class

Advantage of return method calculating sum of areas public class Box{int

Box{
int length;
int width;
 
Int calculateArea(){
 
int area=length*width;
return area;
 
}
}

public class TestBox{
public static

void main (String[] args){
Box obj1 =new Box();
Box obj2 =new Box();
obj1.length=5;
obj1.width=10;
Int area1=obj1.calculateArea;
obj2.length=15;
obj2.width=2;
Int area2=obj2.calculateArea;
System.out,println(area1+area2);
}
}




Слайд 4 Methods with arguments
public class Box{
int length;
int width;
 
Int calculateArea(int

Methods with arguments public class Box{int length;int width; Int calculateArea(int x){ int area=length*width*x;return

x){
 
int area=length*width*x;
return area;
 
}
}

public class TestBox{
public static void main (String[]

args){
Box obj1 =new Box();
Box obj2 =new Box();
obj1.length=5;
obj1.width=10;
Int area1=obj1.calculateArea(4);
System.out.println(area1);
}
}





Слайд 5 Methods with arguments
public class Box{
int length;
int width;
 
Int calculateArea(int

Methods with arguments public class Box{int length;int width; Int calculateArea(int length,int width){ int

length,int width){
 
int area=length*width;
return area;
 
}
}

public class TestBox{
public static void main

(String[] args){
Box obj1 =new Box();
Box obj2 =new Box();
obj1.length=5;
obj1.width=10;
Int area1=obj1.calculateArea(4,3);
System.out.println(area1);
}
}

Output 12






Слайд 6 Methods with arguments
public class Box{
int length;
int width;
 
Int calculateArea(

Methods with arguments public class Box{int length;int width; Int calculateArea( int length,int

int length,int width){
 
int area=this.length*this.width;
return area;
 
}
}

public class TestBox{
public static void

main (String[] args){
Box obj1 =new Box();
Box obj2 =new Box();
obj1.length=5;
obj1.width=10;
Int area1=obj1.calculateArea(4,3);
System.out.println(area1);
}
}

Output 50






Слайд 7 Constructors
public class SmallBox{
int length;
int width;
 
SmallBox(int length, int width)

Constructors public class SmallBox{int length;int width; SmallBox(int length, int width) {this.length =

{
this.length = length;
this.width=width;
}

void calculateArea( ){
 
System.out.println(“Area is” +(length+width));
 
}
}

public class TestSmallBox{
public

static void main (String[] args){
SmallBox obj1 =new SmallBox(3,4);
obj1.calculateArea();
}
}

Output ?






Слайд 8 if you want some defalt value you can

if you want some defalt value you can use a constructor(initial

use a constructor(initial defalt values) Concructors have the same name

as class Doesn’t’t return anything including void

public class SmallBox{
int length;
int width;
 
SmallBox( ){
 
this.length=5;
this.width=6;
}
 
void calculateArea(){
System.out.println(“Area”+(length+width));
}
}

public class TestBox{
public static void main (String[] args){
SmallBox obj1 =new Employee();
obj1.calculateArea();
}
}

Output ?







Constructors


Слайд 9 if you want some defalt value you can

if you want some defalt value you can use a constructor(initial

use a constructor(initial defalt values) Concructors have the same name

as class Doesn’t’t return anything including void

public class SmallBox{
int length;
int width;
 
SmallBox(int length,int width ){
 
this.length=length;
this.width=width;
}
 
void calculateArea(){
System.out.println(“Area”+(length+width));
}
}

public class TestBox{
public static void main (String[] args){
Box obj1 =new Employee();
obj1.calculateArea();
}
}

Output ?







Constructors with parameters


  • Имя файла: classes-and-objects.pptx
  • Количество просмотров: 109
  • Количество скачиваний: 0