SlideShare a Scribd company logo
Class 6
     Exposure: Group #7
     Return of an object
     The keyword new
     Constructor call



                             Return of an object
The keyword new

     The new keyword is a Java operator that creates the object .
     The new operator precedes a call to a constructor , which initializes the new
      object .


Constructor call

     A constructor can only be called by other constructors or class methods
      (static).

public class BankAccount{
// member attributes or variables
private double balance;
public static int TotalAccounts =0;
// methods
public BankAccount ( ) {
this(0.0); // constructor call has a parameter
}
public BankAccount( double ingreso ) {
balance = write;
incAccount ();
}
public double balance () {
return balance;
}
public static void incCuentas () {
TotalAccounts ++;
}
public void transfer (BankAccount origen ) {
balance += origin. balance;
origin. balance =0;
public class suma2 {

     public int a;
     public int b;
     public int c;

     public suma2(int a, int b)
     {
     this.a=a;
     this.b=b;
     }
     public void setCalculo()
     {
     c=(a+b)*-1;
     }
     public void getMostrar()
     {
          System.out.println("la suma es:"+c);
     }



     /**
       * @param args
       */
     public static void main(String[] args) {
           // TODO Auto-generated method stub
           suma2 e=new suma2(4,5);
           e.setCalculo();
           e.getMostrar();
     }

}

More Related Content

What's hot

Functional Programming in Java - Code for Maintainability
Functional Programming in Java - Code for MaintainabilityFunctional Programming in Java - Code for Maintainability
Functional Programming in Java - Code for Maintainability
Marcin Stepien
 
Formal methods Project Report for the support of slides uploaded
Formal methods Project Report for the support of slides uploaded Formal methods Project Report for the support of slides uploaded
Formal methods Project Report for the support of slides uploaded
Shoaib Haseeb
 
Functions
FunctionsFunctions
Functions
Jesmin Akhter
 
Check the output of the following code then recode it to eliminate fu
 Check the output of the following code then recode it to eliminate fu Check the output of the following code then recode it to eliminate fu
Check the output of the following code then recode it to eliminate fu
licservernoida
 
Cocoa heads 09112017
Cocoa heads 09112017Cocoa heads 09112017
Cocoa heads 09112017
Vincent Pradeilles
 
Data structure lab manual
Data structure lab manualData structure lab manual
Data structure lab manual
nikshaikh786
 
function in c
function in cfunction in c
function in c
subam3
 
NodeJS Spring style Inversifyjs
NodeJS Spring style InversifyjsNodeJS Spring style Inversifyjs
NodeJS Spring style Inversifyjs
Mathieu Breton
 
Advanced functional programing in Swift
Advanced functional programing in SwiftAdvanced functional programing in Swift
Advanced functional programing in Swift
Vincent Pradeilles
 
Lambda Expressions in C++
Lambda Expressions in C++Lambda Expressions in C++
Lambda Expressions in C++
Patrick Viafore
 
The Ring programming language version 1.8 book - Part 86 of 202
The Ring programming language version 1.8 book - Part 86 of 202The Ring programming language version 1.8 book - Part 86 of 202
The Ring programming language version 1.8 book - Part 86 of 202
Mahmoud Samir Fayed
 
Working with functions in matlab
Working with functions in matlabWorking with functions in matlab
Working with functions in matlab
harman kaur
 
C programming function
C  programming functionC  programming function
C programming function
argusacademy
 
C Programming Language Part 6
C Programming Language Part 6C Programming Language Part 6
C Programming Language Part 6
Rumman Ansari
 
Introduction to JQ
Introduction to JQIntroduction to JQ
Introduction to JQ
Knoldus Inc.
 
jq: JSON - Like a Boss
jq: JSON - Like a Bossjq: JSON - Like a Boss
jq: JSON - Like a Boss
Bob Tiernay
 
print even or odd number in c
print even or odd number in cprint even or odd number in c
print even or odd number in c
mohdshanu
 
Concurrency on the JVM
Concurrency on the JVMConcurrency on the JVM
Concurrency on the JVMVaclav Pech
 

What's hot (20)

Functional Programming in Java - Code for Maintainability
Functional Programming in Java - Code for MaintainabilityFunctional Programming in Java - Code for Maintainability
Functional Programming in Java - Code for Maintainability
 
Formal methods Project Report for the support of slides uploaded
Formal methods Project Report for the support of slides uploaded Formal methods Project Report for the support of slides uploaded
Formal methods Project Report for the support of slides uploaded
 
Functions
FunctionsFunctions
Functions
 
Check the output of the following code then recode it to eliminate fu
 Check the output of the following code then recode it to eliminate fu Check the output of the following code then recode it to eliminate fu
Check the output of the following code then recode it to eliminate fu
 
Chap 9(functions)
Chap 9(functions)Chap 9(functions)
Chap 9(functions)
 
Cocoa heads 09112017
Cocoa heads 09112017Cocoa heads 09112017
Cocoa heads 09112017
 
Data structure lab manual
Data structure lab manualData structure lab manual
Data structure lab manual
 
function in c
function in cfunction in c
function in c
 
NodeJS Spring style Inversifyjs
NodeJS Spring style InversifyjsNodeJS Spring style Inversifyjs
NodeJS Spring style Inversifyjs
 
Advanced functional programing in Swift
Advanced functional programing in SwiftAdvanced functional programing in Swift
Advanced functional programing in Swift
 
Lambda Expressions in C++
Lambda Expressions in C++Lambda Expressions in C++
Lambda Expressions in C++
 
The Ring programming language version 1.8 book - Part 86 of 202
The Ring programming language version 1.8 book - Part 86 of 202The Ring programming language version 1.8 book - Part 86 of 202
The Ring programming language version 1.8 book - Part 86 of 202
 
Working with functions in matlab
Working with functions in matlabWorking with functions in matlab
Working with functions in matlab
 
C programming function
C  programming functionC  programming function
C programming function
 
C Programming Language Part 6
C Programming Language Part 6C Programming Language Part 6
C Programming Language Part 6
 
Introduction to JQ
Introduction to JQIntroduction to JQ
Introduction to JQ
 
Quiz 10 cp_sol
Quiz 10 cp_solQuiz 10 cp_sol
Quiz 10 cp_sol
 
jq: JSON - Like a Boss
jq: JSON - Like a Bossjq: JSON - Like a Boss
jq: JSON - Like a Boss
 
print even or odd number in c
print even or odd number in cprint even or odd number in c
print even or odd number in c
 
Concurrency on the JVM
Concurrency on the JVMConcurrency on the JVM
Concurrency on the JVM
 

Viewers also liked

Nuevas formas de comunicación (ntic’s)
Nuevas formas de comunicación (ntic’s)Nuevas formas de comunicación (ntic’s)
Nuevas formas de comunicación (ntic’s)vanevata
 
Los Cocodrilos del Pampita.
Los Cocodrilos del Pampita.Los Cocodrilos del Pampita.
Los Cocodrilos del Pampita.
laurafarosi
 
Tapak pembelajaran Bahasa Malaysia
Tapak pembelajaran Bahasa Malaysia Tapak pembelajaran Bahasa Malaysia
Tapak pembelajaran Bahasa Malaysia
Caeser Rio
 
แนะนำตัว โบ
แนะนำตัว โบแนะนำตัว โบ
แนะนำตัว โบpuangtong
 
Como crear una cuenta en youtube y subir un video
Como crear una cuenta en youtube y subir un videoComo crear una cuenta en youtube y subir un video
Como crear una cuenta en youtube y subir un video
linasofiavasquez
 
Membina dan menggunakan tapak, laman web utk p&p
Membina dan menggunakan tapak, laman web  utk p&pMembina dan menggunakan tapak, laman web  utk p&p
Membina dan menggunakan tapak, laman web utk p&p
Permata_An-Nur
 
Presentación final2
Presentación final2Presentación final2
Presentación final2CUN
 
Trabajo Práctico de TIC
Trabajo Práctico de TICTrabajo Práctico de TIC
Trabajo Práctico de TIC
gueler
 
Que significa información dixital
Que significa información dixitalQue significa información dixital
Que significa información dixitalfernando malvar
 
Mi programa de_formacion
Mi programa de_formacion Mi programa de_formacion
Mi programa de_formacion daimer1995
 
Un indipendente è per sempre - By Marco Mozzoni
Un indipendente è per sempre - By Marco MozzoniUn indipendente è per sempre - By Marco Mozzoni
Un indipendente è per sempre - By Marco Mozzoni
Marco Mozzoni
 
Alum
AlumAlum
Alumcanch
 
Domínguez, julia
Domínguez, juliaDomínguez, julia
Domínguez, julia
odilemartinfuentes
 
romance del prisionero
romance del prisioneroromance del prisionero
romance del prisioneroirenitah97
 

Viewers also liked (20)

Nuevas formas de comunicación (ntic’s)
Nuevas formas de comunicación (ntic’s)Nuevas formas de comunicación (ntic’s)
Nuevas formas de comunicación (ntic’s)
 
Rubricas
RubricasRubricas
Rubricas
 
Los Cocodrilos del Pampita.
Los Cocodrilos del Pampita.Los Cocodrilos del Pampita.
Los Cocodrilos del Pampita.
 
Tapak pembelajaran Bahasa Malaysia
Tapak pembelajaran Bahasa Malaysia Tapak pembelajaran Bahasa Malaysia
Tapak pembelajaran Bahasa Malaysia
 
แนะนำตัว โบ
แนะนำตัว โบแนะนำตัว โบ
แนะนำตัว โบ
 
Escaner
EscanerEscaner
Escaner
 
Lol
LolLol
Lol
 
Como crear una cuenta en youtube y subir un video
Como crear una cuenta en youtube y subir un videoComo crear una cuenta en youtube y subir un video
Como crear una cuenta en youtube y subir un video
 
Capitulo ii
Capitulo iiCapitulo ii
Capitulo ii
 
Membina dan menggunakan tapak, laman web utk p&p
Membina dan menggunakan tapak, laman web  utk p&pMembina dan menggunakan tapak, laman web  utk p&p
Membina dan menggunakan tapak, laman web utk p&p
 
Presentación final2
Presentación final2Presentación final2
Presentación final2
 
Trabajo Práctico de TIC
Trabajo Práctico de TICTrabajo Práctico de TIC
Trabajo Práctico de TIC
 
Que significa información dixital
Que significa información dixitalQue significa información dixital
Que significa información dixital
 
Mi programa de_formacion
Mi programa de_formacion Mi programa de_formacion
Mi programa de_formacion
 
Un indipendente è per sempre - By Marco Mozzoni
Un indipendente è per sempre - By Marco MozzoniUn indipendente è per sempre - By Marco Mozzoni
Un indipendente è per sempre - By Marco Mozzoni
 
Kata sendi
Kata sendiKata sendi
Kata sendi
 
Alum
AlumAlum
Alum
 
Domínguez, julia
Domínguez, juliaDomínguez, julia
Domínguez, julia
 
romance del prisionero
romance del prisioneroromance del prisionero
romance del prisionero
 
Tarea 6
Tarea 6Tarea 6
Tarea 6
 

Similar to Class 6 2ciclo

OBJECT ORIENTED PROGRAMMIING LANGUAGE PROGRAMS
OBJECT ORIENTED PROGRAMMIING LANGUAGE PROGRAMSOBJECT ORIENTED PROGRAMMIING LANGUAGE PROGRAMS
OBJECT ORIENTED PROGRAMMIING LANGUAGE PROGRAMS
Rohit Kumar
 
Java doc Pr ITM2
Java doc Pr ITM2Java doc Pr ITM2
Java doc Pr ITM2
Aram Mohammed
 
Java 8 lambda expressions
Java 8 lambda expressionsJava 8 lambda expressions
Java 8 lambda expressions
Logan Chien
 
Chap2 class,objects contd
Chap2 class,objects contdChap2 class,objects contd
Chap2 class,objects contd
raksharao
 
PROGRAMING IN JAVA 4TH SEM DIGVIJAY COLLAGE
PROGRAMING IN JAVA 4TH SEM DIGVIJAY COLLAGEPROGRAMING IN JAVA 4TH SEM DIGVIJAY COLLAGE
PROGRAMING IN JAVA 4TH SEM DIGVIJAY COLLAGE
yash production
 
Java programI made this Account.java below. Using the attached cod.pdf
Java programI made this Account.java below. Using the attached cod.pdfJava programI made this Account.java below. Using the attached cod.pdf
Java programI made this Account.java below. Using the attached cod.pdf
fathimafancy
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Mar-2021_L14...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Mar-2021_L14...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Mar-2021_L14...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Mar-2021_L14...
MaruMengesha
 
Algoritmos sujei
Algoritmos sujeiAlgoritmos sujei
Algoritmos sujei
gersonjack
 
@author public class Person{   String sname, .pdf
  @author   public class Person{   String sname, .pdf  @author   public class Person{   String sname, .pdf
@author public class Person{   String sname, .pdf
aplolomedicalstoremr
 
Padroes Projeto
Padroes ProjetoPadroes Projeto
Padroes Projetolcbj
 
Java Programs
Java ProgramsJava Programs
Java Programs
vvpadhu
 
Java ppt Gandhi Ravi (gandhiri@gmail.com)
Java ppt  Gandhi Ravi  (gandhiri@gmail.com)Java ppt  Gandhi Ravi  (gandhiri@gmail.com)
Java ppt Gandhi Ravi (gandhiri@gmail.com)
Gandhi Ravi
 
Unit-3 Practice Programs-5.docx
Unit-3 Practice Programs-5.docxUnit-3 Practice Programs-5.docx
Unit-3 Practice Programs-5.docx
R.K.College of engg & Tech
 
Test program
Test programTest program
operating system linux,ubuntu,Mac Geometri.pdf
operating system linux,ubuntu,Mac Geometri.pdfoperating system linux,ubuntu,Mac Geometri.pdf
operating system linux,ubuntu,Mac Geometri.pdf
aquadreammail
 
C# programs
C# programsC# programs
C# programs
Gourav Pant
 
Virtual function
Virtual functionVirtual function
Virtual function
harman kaur
 
OOP in C - Before GObject (Chinese Version)
OOP in C - Before GObject (Chinese Version)OOP in C - Before GObject (Chinese Version)
OOP in C - Before GObject (Chinese Version)Kai-Feng Chou
 

Similar to Class 6 2ciclo (20)

OBJECT ORIENTED PROGRAMMIING LANGUAGE PROGRAMS
OBJECT ORIENTED PROGRAMMIING LANGUAGE PROGRAMSOBJECT ORIENTED PROGRAMMIING LANGUAGE PROGRAMS
OBJECT ORIENTED PROGRAMMIING LANGUAGE PROGRAMS
 
Java doc Pr ITM2
Java doc Pr ITM2Java doc Pr ITM2
Java doc Pr ITM2
 
Java 8 lambda expressions
Java 8 lambda expressionsJava 8 lambda expressions
Java 8 lambda expressions
 
C# labprograms
C# labprogramsC# labprograms
C# labprograms
 
Chap2 class,objects contd
Chap2 class,objects contdChap2 class,objects contd
Chap2 class,objects contd
 
PROGRAMING IN JAVA 4TH SEM DIGVIJAY COLLAGE
PROGRAMING IN JAVA 4TH SEM DIGVIJAY COLLAGEPROGRAMING IN JAVA 4TH SEM DIGVIJAY COLLAGE
PROGRAMING IN JAVA 4TH SEM DIGVIJAY COLLAGE
 
Java programI made this Account.java below. Using the attached cod.pdf
Java programI made this Account.java below. Using the attached cod.pdfJava programI made this Account.java below. Using the attached cod.pdf
Java programI made this Account.java below. Using the attached cod.pdf
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Mar-2021_L14...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Mar-2021_L14...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Mar-2021_L14...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Mar-2021_L14...
 
Algoritmos sujei
Algoritmos sujeiAlgoritmos sujei
Algoritmos sujei
 
@author public class Person{   String sname, .pdf
  @author   public class Person{   String sname, .pdf  @author   public class Person{   String sname, .pdf
@author public class Person{   String sname, .pdf
 
Padroes Projeto
Padroes ProjetoPadroes Projeto
Padroes Projeto
 
Thread
ThreadThread
Thread
 
Java Programs
Java ProgramsJava Programs
Java Programs
 
Java ppt Gandhi Ravi (gandhiri@gmail.com)
Java ppt  Gandhi Ravi  (gandhiri@gmail.com)Java ppt  Gandhi Ravi  (gandhiri@gmail.com)
Java ppt Gandhi Ravi (gandhiri@gmail.com)
 
Unit-3 Practice Programs-5.docx
Unit-3 Practice Programs-5.docxUnit-3 Practice Programs-5.docx
Unit-3 Practice Programs-5.docx
 
Test program
Test programTest program
Test program
 
operating system linux,ubuntu,Mac Geometri.pdf
operating system linux,ubuntu,Mac Geometri.pdfoperating system linux,ubuntu,Mac Geometri.pdf
operating system linux,ubuntu,Mac Geometri.pdf
 
C# programs
C# programsC# programs
C# programs
 
Virtual function
Virtual functionVirtual function
Virtual function
 
OOP in C - Before GObject (Chinese Version)
OOP in C - Before GObject (Chinese Version)OOP in C - Before GObject (Chinese Version)
OOP in C - Before GObject (Chinese Version)
 

More from Carlos Alcivar

Portafolio de ingles carlos alcivar mera
Portafolio de ingles   carlos alcivar meraPortafolio de ingles   carlos alcivar mera
Portafolio de ingles carlos alcivar meraCarlos Alcivar
 
Portafolio de ingles carlos alcivar mera
Portafolio de ingles   carlos alcivar meraPortafolio de ingles   carlos alcivar mera
Portafolio de ingles carlos alcivar meraCarlos Alcivar
 
Gestor de proyectos_de_clase
Gestor de proyectos_de_claseGestor de proyectos_de_clase
Gestor de proyectos_de_claseCarlos Alcivar
 
Portafolio calculo diferencial 2 a
Portafolio calculo diferencial 2 aPortafolio calculo diferencial 2 a
Portafolio calculo diferencial 2 aCarlos Alcivar
 
Portafolio calculo diferencial 2 a
Portafolio calculo diferencial 2 aPortafolio calculo diferencial 2 a
Portafolio calculo diferencial 2 a
Carlos Alcivar
 
Portafolio calculo diferencial 2 a
Portafolio calculo diferencial 2 aPortafolio calculo diferencial 2 a
Portafolio calculo diferencial 2 aCarlos Alcivar
 
Portafolio calculo diferencial 2 a
Portafolio calculo diferencial 2 aPortafolio calculo diferencial 2 a
Portafolio calculo diferencial 2 aCarlos Alcivar
 

More from Carlos Alcivar (14)

Ingles portafolio
Ingles portafolioIngles portafolio
Ingles portafolio
 
Portafolio de ingles carlos alcivar mera
Portafolio de ingles   carlos alcivar meraPortafolio de ingles   carlos alcivar mera
Portafolio de ingles carlos alcivar mera
 
Portafolio de ingles carlos alcivar mera
Portafolio de ingles   carlos alcivar meraPortafolio de ingles   carlos alcivar mera
Portafolio de ingles carlos alcivar mera
 
Proyect of english
Proyect of englishProyect of english
Proyect of english
 
Gestor de proyectos_de_clase
Gestor de proyectos_de_claseGestor de proyectos_de_clase
Gestor de proyectos_de_clase
 
Class 7 2ciclo
Class 7 2cicloClass 7 2ciclo
Class 7 2ciclo
 
Class 5 2ciclo
Class 5 2cicloClass 5 2ciclo
Class 5 2ciclo
 
Class 4 2ciclo
Class 4 2cicloClass 4 2ciclo
Class 4 2ciclo
 
Class 3 2ciclo
Class 3 2cicloClass 3 2ciclo
Class 3 2ciclo
 
Class 1 y 2 2ciclo
Class 1 y 2 2cicloClass 1 y 2 2ciclo
Class 1 y 2 2ciclo
 
Portafolio calculo diferencial 2 a
Portafolio calculo diferencial 2 aPortafolio calculo diferencial 2 a
Portafolio calculo diferencial 2 a
 
Portafolio calculo diferencial 2 a
Portafolio calculo diferencial 2 aPortafolio calculo diferencial 2 a
Portafolio calculo diferencial 2 a
 
Portafolio calculo diferencial 2 a
Portafolio calculo diferencial 2 aPortafolio calculo diferencial 2 a
Portafolio calculo diferencial 2 a
 
Portafolio calculo diferencial 2 a
Portafolio calculo diferencial 2 aPortafolio calculo diferencial 2 a
Portafolio calculo diferencial 2 a
 

Class 6 2ciclo

  • 1. Class 6  Exposure: Group #7  Return of an object  The keyword new  Constructor call Return of an object The keyword new  The new keyword is a Java operator that creates the object .  The new operator precedes a call to a constructor , which initializes the new object . Constructor call  A constructor can only be called by other constructors or class methods (static). public class BankAccount{ // member attributes or variables private double balance; public static int TotalAccounts =0; // methods public BankAccount ( ) { this(0.0); // constructor call has a parameter } public BankAccount( double ingreso ) { balance = write; incAccount (); } public double balance () { return balance; } public static void incCuentas () { TotalAccounts ++; } public void transfer (BankAccount origen ) { balance += origin. balance; origin. balance =0;
  • 2. public class suma2 { public int a; public int b; public int c; public suma2(int a, int b) { this.a=a; this.b=b; } public void setCalculo() { c=(a+b)*-1; } public void getMostrar() { System.out.println("la suma es:"+c); } /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub suma2 e=new suma2(4,5); e.setCalculo(); e.getMostrar(); } }