SlideShare a Scribd company logo
1 of 5
Download to read offline
import java.util.*;
import java.lang.*;
import java.io.*;
class Phone
{
private String phonebook;
private String listofcalls;
private String textmessages;
public Phone(String pb,String lc,String tm) //parameterized constructor to initialize variables
{
phonebook=pb;
listofcalls=lc;
textmessages=tm;
}
public void clear(PhotoAlbum album) // clear the contents of Phone and PhotoAlbum object
{
phonebook=null;
listofcalls=null;
textmessages=null;
}
public void display() //display variables
{
System.out.println(" phonebook ="+phonebook+" listof calls= "+listofcalls+"
textmessages= "+textmessages);
}
}
class PhotoAlbum
{
private String pics;
public PhotoAlbum(String p) //parameterized constructor to initialize variable
{
pics=p;
}
public void clear() //clear the variable
{
pics=null;
}
public void display() //display variable
{
System.out.println(" Pictures= "+pics);
}
}
class CameraPhone extends Phone
{
public CameraPhone(String phbook,String callist,String messages)
{
super(phbook,callist,messages); // call to base class parameterized constructor
}
public void clear(PhotoAlbum album)
{
super.clear(album); // call to base class clear method
album.clear();
}
}
class TestClear
{
public static void main (String[] args) throws java.lang.Exception
{
Phone camphone=new CameraPhone("phonebook","callist","messages");
PhotoAlbum album=new PhotoAlbum("pictures");
camphone.clear(album); // overriding base class method clear()
camphone.display();
album.display();
}
}
output
Success time: 0.04 memory: 711168 signal:0
Solution
import java.util.*;
import java.lang.*;
import java.io.*;
class Phone
{
private String phonebook;
private String listofcalls;
private String textmessages;
public Phone(String pb,String lc,String tm) //parameterized constructor to initialize variables
{
phonebook=pb;
listofcalls=lc;
textmessages=tm;
}
public void clear(PhotoAlbum album) // clear the contents of Phone and PhotoAlbum object
{
phonebook=null;
listofcalls=null;
textmessages=null;
}
public void display() //display variables
{
System.out.println(" phonebook ="+phonebook+" listof calls= "+listofcalls+"
textmessages= "+textmessages);
}
}
class PhotoAlbum
{
private String pics;
public PhotoAlbum(String p) //parameterized constructor to initialize variable
{
pics=p;
}
public void clear() //clear the variable
{
pics=null;
}
public void display() //display variable
{
System.out.println(" Pictures= "+pics);
}
}
class CameraPhone extends Phone
{
public CameraPhone(String phbook,String callist,String messages)
{
super(phbook,callist,messages); // call to base class parameterized constructor
}
public void clear(PhotoAlbum album)
{
super.clear(album); // call to base class clear method
album.clear();
}
}
class TestClear
{
public static void main (String[] args) throws java.lang.Exception
{
Phone camphone=new CameraPhone("phonebook","callist","messages");
PhotoAlbum album=new PhotoAlbum("pictures");
camphone.clear(album); // overriding base class method clear()
camphone.display();
album.display();
}
}
output
Success time: 0.04 memory: 711168 signal:0

More Related Content

More from anubhavnigam2608

1.KClO(3) ---- Potassium chlorate 2.H(2)SO(2) ------ sulphurous acid.pdf
  1.KClO(3) ---- Potassium chlorate 2.H(2)SO(2) ------ sulphurous acid.pdf  1.KClO(3) ---- Potassium chlorate 2.H(2)SO(2) ------ sulphurous acid.pdf
1.KClO(3) ---- Potassium chlorate 2.H(2)SO(2) ------ sulphurous acid.pdfanubhavnigam2608
 
Seven Requirements of CTC 1 Age 2 Relationship .pdf
     Seven Requirements of CTC           1 Age     2 Relationship    .pdf     Seven Requirements of CTC           1 Age     2 Relationship    .pdf
Seven Requirements of CTC 1 Age 2 Relationship .pdfanubhavnigam2608
 
the solvents that are used to combine together to.pdf
                     the solvents that are used to combine together to.pdf                     the solvents that are used to combine together to.pdf
the solvents that are used to combine together to.pdfanubhavnigam2608
 
The most simple property to calculate this is Ka.pdf
                     The most simple property to calculate this is Ka.pdf                     The most simple property to calculate this is Ka.pdf
The most simple property to calculate this is Ka.pdfanubhavnigam2608
 
The images of the compounds are not visible. Kin.pdf
                     The images of the compounds are not visible.  Kin.pdf                     The images of the compounds are not visible.  Kin.pdf
The images of the compounds are not visible. Kin.pdfanubhavnigam2608
 
Step1 Moles of water produced =18 Step2 The init.pdf
                     Step1 Moles of water produced =18  Step2 The init.pdf                     Step1 Moles of water produced =18  Step2 The init.pdf
Step1 Moles of water produced =18 Step2 The init.pdfanubhavnigam2608
 
Sorry. SnO2 is amphoteric. This one is a tricky o.pdf
                     Sorry. SnO2 is amphoteric. This one is a tricky o.pdf                     Sorry. SnO2 is amphoteric. This one is a tricky o.pdf
Sorry. SnO2 is amphoteric. This one is a tricky o.pdfanubhavnigam2608
 
scientific synonyms for height may be peak or tal.pdf
                     scientific synonyms for height may be peak or tal.pdf                     scientific synonyms for height may be peak or tal.pdf
scientific synonyms for height may be peak or tal.pdfanubhavnigam2608
 
R = k[NOCl2][NO] Molecularity = 2 .pdf
                     R = k[NOCl2][NO]  Molecularity = 2               .pdf                     R = k[NOCl2][NO]  Molecularity = 2               .pdf
R = k[NOCl2][NO] Molecularity = 2 .pdfanubhavnigam2608
 
In general, they are alkenes attached to electron.pdf
                     In general, they are alkenes attached to electron.pdf                     In general, they are alkenes attached to electron.pdf
In general, they are alkenes attached to electron.pdfanubhavnigam2608
 
Group 11 has three elements namely, Cu, Ag and Au.pdf
                     Group 11 has three elements namely, Cu, Ag and Au.pdf                     Group 11 has three elements namely, Cu, Ag and Au.pdf
Group 11 has three elements namely, Cu, Ag and Au.pdfanubhavnigam2608
 
Cu, (H2), Zn, Mg Activity series basedon hyd.pdf
                     Cu, (H2), Zn, Mg  Activity series basedon hyd.pdf                     Cu, (H2), Zn, Mg  Activity series basedon hyd.pdf
Cu, (H2), Zn, Mg Activity series basedon hyd.pdfanubhavnigam2608
 
answewrSolutionanswewr.pdf
answewrSolutionanswewr.pdfanswewrSolutionanswewr.pdf
answewrSolutionanswewr.pdfanubhavnigam2608
 
When a compound is completely oxidized with oxygen, the products wil.pdf
When a compound is completely oxidized with oxygen, the products wil.pdfWhen a compound is completely oxidized with oxygen, the products wil.pdf
When a compound is completely oxidized with oxygen, the products wil.pdfanubhavnigam2608
 
Calcium metal reacts with liquid water to produce.pdf
                     Calcium metal reacts with liquid water to produce.pdf                     Calcium metal reacts with liquid water to produce.pdf
Calcium metal reacts with liquid water to produce.pdfanubhavnigam2608
 
The mineralogical and structural adjustment of solid rocks to physic.pdf
The mineralogical and structural adjustment of solid rocks to physic.pdfThe mineralogical and structural adjustment of solid rocks to physic.pdf
The mineralogical and structural adjustment of solid rocks to physic.pdfanubhavnigam2608
 

More from anubhavnigam2608 (20)

1.KClO(3) ---- Potassium chlorate 2.H(2)SO(2) ------ sulphurous acid.pdf
  1.KClO(3) ---- Potassium chlorate 2.H(2)SO(2) ------ sulphurous acid.pdf  1.KClO(3) ---- Potassium chlorate 2.H(2)SO(2) ------ sulphurous acid.pdf
1.KClO(3) ---- Potassium chlorate 2.H(2)SO(2) ------ sulphurous acid.pdf
 
Seven Requirements of CTC 1 Age 2 Relationship .pdf
     Seven Requirements of CTC           1 Age     2 Relationship    .pdf     Seven Requirements of CTC           1 Age     2 Relationship    .pdf
Seven Requirements of CTC 1 Age 2 Relationship .pdf
 
the solvents that are used to combine together to.pdf
                     the solvents that are used to combine together to.pdf                     the solvents that are used to combine together to.pdf
the solvents that are used to combine together to.pdf
 
The most simple property to calculate this is Ka.pdf
                     The most simple property to calculate this is Ka.pdf                     The most simple property to calculate this is Ka.pdf
The most simple property to calculate this is Ka.pdf
 
The images of the compounds are not visible. Kin.pdf
                     The images of the compounds are not visible.  Kin.pdf                     The images of the compounds are not visible.  Kin.pdf
The images of the compounds are not visible. Kin.pdf
 
Step1 Moles of water produced =18 Step2 The init.pdf
                     Step1 Moles of water produced =18  Step2 The init.pdf                     Step1 Moles of water produced =18  Step2 The init.pdf
Step1 Moles of water produced =18 Step2 The init.pdf
 
Sorry. SnO2 is amphoteric. This one is a tricky o.pdf
                     Sorry. SnO2 is amphoteric. This one is a tricky o.pdf                     Sorry. SnO2 is amphoteric. This one is a tricky o.pdf
Sorry. SnO2 is amphoteric. This one is a tricky o.pdf
 
SO2 Solu.pdf
                     SO2                                      Solu.pdf                     SO2                                      Solu.pdf
SO2 Solu.pdf
 
scientific synonyms for height may be peak or tal.pdf
                     scientific synonyms for height may be peak or tal.pdf                     scientific synonyms for height may be peak or tal.pdf
scientific synonyms for height may be peak or tal.pdf
 
R = k[NOCl2][NO] Molecularity = 2 .pdf
                     R = k[NOCl2][NO]  Molecularity = 2               .pdf                     R = k[NOCl2][NO]  Molecularity = 2               .pdf
R = k[NOCl2][NO] Molecularity = 2 .pdf
 
In general, they are alkenes attached to electron.pdf
                     In general, they are alkenes attached to electron.pdf                     In general, they are alkenes attached to electron.pdf
In general, they are alkenes attached to electron.pdf
 
I, II S.pdf
                     I, II                                       S.pdf                     I, II                                       S.pdf
I, II S.pdf
 
Group 11 has three elements namely, Cu, Ag and Au.pdf
                     Group 11 has three elements namely, Cu, Ag and Au.pdf                     Group 11 has three elements namely, Cu, Ag and Au.pdf
Group 11 has three elements namely, Cu, Ag and Au.pdf
 
Cu, (H2), Zn, Mg Activity series basedon hyd.pdf
                     Cu, (H2), Zn, Mg  Activity series basedon hyd.pdf                     Cu, (H2), Zn, Mg  Activity series basedon hyd.pdf
Cu, (H2), Zn, Mg Activity series basedon hyd.pdf
 
answewrSolutionanswewr.pdf
answewrSolutionanswewr.pdfanswewrSolutionanswewr.pdf
answewrSolutionanswewr.pdf
 
cis- So.pdf
                     cis-                                       So.pdf                     cis-                                       So.pdf
cis- So.pdf
 
When a compound is completely oxidized with oxygen, the products wil.pdf
When a compound is completely oxidized with oxygen, the products wil.pdfWhen a compound is completely oxidized with oxygen, the products wil.pdf
When a compound is completely oxidized with oxygen, the products wil.pdf
 
Calcium metal reacts with liquid water to produce.pdf
                     Calcium metal reacts with liquid water to produce.pdf                     Calcium metal reacts with liquid water to produce.pdf
Calcium metal reacts with liquid water to produce.pdf
 
two;Solutiontwo;.pdf
two;Solutiontwo;.pdftwo;Solutiontwo;.pdf
two;Solutiontwo;.pdf
 
The mineralogical and structural adjustment of solid rocks to physic.pdf
The mineralogical and structural adjustment of solid rocks to physic.pdfThe mineralogical and structural adjustment of solid rocks to physic.pdf
The mineralogical and structural adjustment of solid rocks to physic.pdf
 

Recently uploaded

How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17Celine George
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...EduSkills OECD
 
Book Review of Run For Your Life Powerpoint
Book Review of Run For Your Life PowerpointBook Review of Run For Your Life Powerpoint
Book Review of Run For Your Life Powerpoint23600690
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...EADTU
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppCeline George
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................MirzaAbrarBaig5
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi RajagopalEADTU
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...Nguyen Thanh Tu Collection
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code ExamplesPeter Brusilovsky
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismDabee Kamal
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhleson0603
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppCeline George
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...Nguyen Thanh Tu Collection
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...Nguyen Thanh Tu Collection
 

Recently uploaded (20)

How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
Book Review of Run For Your Life Powerpoint
Book Review of Run For Your Life PowerpointBook Review of Run For Your Life Powerpoint
Book Review of Run For Your Life Powerpoint
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................
 
Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 
Supporting Newcomer Multilingual Learners
Supporting Newcomer  Multilingual LearnersSupporting Newcomer  Multilingual Learners
Supporting Newcomer Multilingual Learners
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in Hinduism
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge App
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 

import java.util.; import java.lang.; import java.io.;c.pdf

  • 1. import java.util.*; import java.lang.*; import java.io.*; class Phone { private String phonebook; private String listofcalls; private String textmessages; public Phone(String pb,String lc,String tm) //parameterized constructor to initialize variables { phonebook=pb; listofcalls=lc; textmessages=tm; } public void clear(PhotoAlbum album) // clear the contents of Phone and PhotoAlbum object { phonebook=null; listofcalls=null; textmessages=null; } public void display() //display variables { System.out.println(" phonebook ="+phonebook+" listof calls= "+listofcalls+" textmessages= "+textmessages); } } class PhotoAlbum { private String pics; public PhotoAlbum(String p) //parameterized constructor to initialize variable {
  • 2. pics=p; } public void clear() //clear the variable { pics=null; } public void display() //display variable { System.out.println(" Pictures= "+pics); } } class CameraPhone extends Phone { public CameraPhone(String phbook,String callist,String messages) { super(phbook,callist,messages); // call to base class parameterized constructor } public void clear(PhotoAlbum album) { super.clear(album); // call to base class clear method album.clear(); } } class TestClear { public static void main (String[] args) throws java.lang.Exception { Phone camphone=new CameraPhone("phonebook","callist","messages"); PhotoAlbum album=new PhotoAlbum("pictures"); camphone.clear(album); // overriding base class method clear() camphone.display(); album.display(); }
  • 3. } output Success time: 0.04 memory: 711168 signal:0 Solution import java.util.*; import java.lang.*; import java.io.*; class Phone { private String phonebook; private String listofcalls; private String textmessages; public Phone(String pb,String lc,String tm) //parameterized constructor to initialize variables { phonebook=pb; listofcalls=lc; textmessages=tm; } public void clear(PhotoAlbum album) // clear the contents of Phone and PhotoAlbum object { phonebook=null; listofcalls=null; textmessages=null; } public void display() //display variables { System.out.println(" phonebook ="+phonebook+" listof calls= "+listofcalls+" textmessages= "+textmessages); } }
  • 4. class PhotoAlbum { private String pics; public PhotoAlbum(String p) //parameterized constructor to initialize variable { pics=p; } public void clear() //clear the variable { pics=null; } public void display() //display variable { System.out.println(" Pictures= "+pics); } } class CameraPhone extends Phone { public CameraPhone(String phbook,String callist,String messages) { super(phbook,callist,messages); // call to base class parameterized constructor } public void clear(PhotoAlbum album) { super.clear(album); // call to base class clear method album.clear(); } } class TestClear { public static void main (String[] args) throws java.lang.Exception { Phone camphone=new CameraPhone("phonebook","callist","messages"); PhotoAlbum album=new PhotoAlbum("pictures");
  • 5. camphone.clear(album); // overriding base class method clear() camphone.display(); album.display(); } } output Success time: 0.04 memory: 711168 signal:0