SlideShare a Scribd company logo
1 of 4
Download to read offline
1. JUnit test for method toString() in SalariedEmployee -
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;
@RunWith(MockitoJUnitRunner.class)
public class SalariedEmployeeTest {
@Test
public void testToString(){
String name="name";
double salary=3000;
double bonus=1000;
SalariedEmployee employee= new SalariedEmployee(name,salary,bonus);
employee.toString();
}
}
2. JAva program to replace "is" with "was" -
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class StringReplace {
public static void main(String[] args) throws IOException {
BufferedReader br = null;
File file = new File("/My Stuffs/Root/Workspace/TestJava/src/com/test/output.txt");
FileWriter fw = new FileWriter(file.getAbsoluteFile());
BufferedWriter bw = new BufferedWriter(fw);
if (!file.exists()) {
file.createNewFile();
}
try {
String sCurrentLine;
br = new BufferedReader(new FileReader("/My
Stuffs/Root/Workspace/TestJava/src/com/test/testing.txt"));
while ((sCurrentLine = br.readLine()) != null) {
System.out.println(sCurrentLine);
String rep=sCurrentLine.replaceAll(" is "," was ");
System.out.println(rep);
bw.write(rep);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (br != null)br.close();
if(bw!=null)bw.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
}
Solution
1. JUnit test for method toString() in SalariedEmployee -
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;
@RunWith(MockitoJUnitRunner.class)
public class SalariedEmployeeTest {
@Test
public void testToString(){
String name="name";
double salary=3000;
double bonus=1000;
SalariedEmployee employee= new SalariedEmployee(name,salary,bonus);
employee.toString();
}
}
2. JAva program to replace "is" with "was" -
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class StringReplace {
public static void main(String[] args) throws IOException {
BufferedReader br = null;
File file = new File("/My Stuffs/Root/Workspace/TestJava/src/com/test/output.txt");
FileWriter fw = new FileWriter(file.getAbsoluteFile());
BufferedWriter bw = new BufferedWriter(fw);
if (!file.exists()) {
file.createNewFile();
}
try {
String sCurrentLine;
br = new BufferedReader(new FileReader("/My
Stuffs/Root/Workspace/TestJava/src/com/test/testing.txt"));
while ((sCurrentLine = br.readLine()) != null) {
System.out.println(sCurrentLine);
String rep=sCurrentLine.replaceAll(" is "," was ");
System.out.println(rep);
bw.write(rep);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (br != null)br.close();
if(bw!=null)bw.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
}

More Related Content

Similar to 1. JUnit test for method toString() in SalariedEmployee -import or.pdf

Write an example of a unit test for a Class methods using JUnitfr.pdf
Write an example of a unit test for a Class methods using JUnitfr.pdfWrite an example of a unit test for a Class methods using JUnitfr.pdf
Write an example of a unit test for a Class methods using JUnitfr.pdfarbaazrabs
 
Object Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsObject Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsMuhammadTalha436
 
The sample program for above series in JAVA will be like belowimpo.pdf
The sample program for above series in JAVA will be like belowimpo.pdfThe sample program for above series in JAVA will be like belowimpo.pdf
The sample program for above series in JAVA will be like belowimpo.pdfrajat630669
 
The sample program for above series in JAVA will be like belowimpo.pdf
The sample program for above series in JAVA will be like belowimpo.pdfThe sample program for above series in JAVA will be like belowimpo.pdf
The sample program for above series in JAVA will be like belowimpo.pdfrajat630669
 
Important java programs(collection+file)
Important java programs(collection+file)Important java programs(collection+file)
Important java programs(collection+file)Alok Kumar
 
Solit 2013, Автоматизация тестирования сложных систем: mixed mode automated t...
Solit 2013, Автоматизация тестирования сложных систем: mixed mode automated t...Solit 2013, Автоматизация тестирования сложных систем: mixed mode automated t...
Solit 2013, Автоматизация тестирования сложных систем: mixed mode automated t...solit
 
First compile all the classes.But to run the program we have to run .pdf
First compile all the classes.But to run the program we have to run .pdfFirst compile all the classes.But to run the program we have to run .pdf
First compile all the classes.But to run the program we have to run .pdfaoneonlinestore1
 
The Java Program for the above given isimport java.io.File;impo.pdf
The Java Program for the above given isimport java.io.File;impo.pdfThe Java Program for the above given isimport java.io.File;impo.pdf
The Java Program for the above given isimport java.io.File;impo.pdfanjanacottonmills
 
package employeeType.employee;public class Employee {   private .pdf
package employeeType.employee;public class Employee {   private .pdfpackage employeeType.employee;public class Employee {   private .pdf
package employeeType.employee;public class Employee {   private .pdfanwarsadath111
 
Android testing
Android testingAndroid testing
Android testingSean Tsai
 
What do you mean it needs to be Java based? How jython saved the day.
What do you mean it needs to be Java based? How jython saved the day.What do you mean it needs to be Java based? How jython saved the day.
What do you mean it needs to be Java based? How jython saved the day.Mark Rees
 
Creating a Facebook Clone - Part XLVI - Transcript.pdf
Creating a Facebook Clone - Part XLVI - Transcript.pdfCreating a Facebook Clone - Part XLVI - Transcript.pdf
Creating a Facebook Clone - Part XLVI - Transcript.pdfShaiAlmog1
 
T.Y.B.S.CS Advance Java Practicals Sem 5 Mumbai University
T.Y.B.S.CS Advance Java Practicals Sem 5 Mumbai UniversityT.Y.B.S.CS Advance Java Practicals Sem 5 Mumbai University
T.Y.B.S.CS Advance Java Practicals Sem 5 Mumbai UniversityNiraj Bharambe
 
Test-driven Development for TYPO3
Test-driven Development for TYPO3Test-driven Development for TYPO3
Test-driven Development for TYPO3Oliver Klee
 

Similar to 1. JUnit test for method toString() in SalariedEmployee -import or.pdf (20)

Write an example of a unit test for a Class methods using JUnitfr.pdf
Write an example of a unit test for a Class methods using JUnitfr.pdfWrite an example of a unit test for a Class methods using JUnitfr.pdf
Write an example of a unit test for a Class methods using JUnitfr.pdf
 
Object Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsObject Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ Exams
 
The sample program for above series in JAVA will be like belowimpo.pdf
The sample program for above series in JAVA will be like belowimpo.pdfThe sample program for above series in JAVA will be like belowimpo.pdf
The sample program for above series in JAVA will be like belowimpo.pdf
 
The sample program for above series in JAVA will be like belowimpo.pdf
The sample program for above series in JAVA will be like belowimpo.pdfThe sample program for above series in JAVA will be like belowimpo.pdf
The sample program for above series in JAVA will be like belowimpo.pdf
 
Important java programs(collection+file)
Important java programs(collection+file)Important java programs(collection+file)
Important java programs(collection+file)
 
Solit 2013, Автоматизация тестирования сложных систем: mixed mode automated t...
Solit 2013, Автоматизация тестирования сложных систем: mixed mode automated t...Solit 2013, Автоматизация тестирования сложных систем: mixed mode automated t...
Solit 2013, Автоматизация тестирования сложных систем: mixed mode automated t...
 
TestNG vs Junit
TestNG vs JunitTestNG vs Junit
TestNG vs Junit
 
First compile all the classes.But to run the program we have to run .pdf
First compile all the classes.But to run the program we have to run .pdfFirst compile all the classes.But to run the program we have to run .pdf
First compile all the classes.But to run the program we have to run .pdf
 
The Java Program for the above given isimport java.io.File;impo.pdf
The Java Program for the above given isimport java.io.File;impo.pdfThe Java Program for the above given isimport java.io.File;impo.pdf
The Java Program for the above given isimport java.io.File;impo.pdf
 
FunctionalInterfaces
FunctionalInterfacesFunctionalInterfaces
FunctionalInterfaces
 
FunctionalInterfaces
FunctionalInterfacesFunctionalInterfaces
FunctionalInterfaces
 
package employeeType.employee;public class Employee {   private .pdf
package employeeType.employee;public class Employee {   private .pdfpackage employeeType.employee;public class Employee {   private .pdf
package employeeType.employee;public class Employee {   private .pdf
 
Android testing
Android testingAndroid testing
Android testing
 
What do you mean it needs to be Java based? How jython saved the day.
What do you mean it needs to be Java based? How jython saved the day.What do you mean it needs to be Java based? How jython saved the day.
What do you mean it needs to be Java based? How jython saved the day.
 
Creating a Facebook Clone - Part XLVI - Transcript.pdf
Creating a Facebook Clone - Part XLVI - Transcript.pdfCreating a Facebook Clone - Part XLVI - Transcript.pdf
Creating a Facebook Clone - Part XLVI - Transcript.pdf
 
Junit and testNG
Junit and testNGJunit and testNG
Junit and testNG
 
T.Y.B.S.CS Advance Java Practicals Sem 5 Mumbai University
T.Y.B.S.CS Advance Java Practicals Sem 5 Mumbai UniversityT.Y.B.S.CS Advance Java Practicals Sem 5 Mumbai University
T.Y.B.S.CS Advance Java Practicals Sem 5 Mumbai University
 
Oop lecture6
Oop lecture6Oop lecture6
Oop lecture6
 
Android TDD
Android TDDAndroid TDD
Android TDD
 
Test-driven Development for TYPO3
Test-driven Development for TYPO3Test-driven Development for TYPO3
Test-driven Development for TYPO3
 

More from arakalamkah11

Particulars $Amount Direct materials 64452 Direct Labour (1332.pdf
    Particulars $Amount   Direct materials 64452   Direct Labour (1332.pdf    Particulars $Amount   Direct materials 64452   Direct Labour (1332.pdf
Particulars $Amount Direct materials 64452 Direct Labour (1332.pdfarakalamkah11
 
Decrease in inventory Source of cash $   440 Decrease in account.pdf
    Decrease in inventory Source of cash $   440   Decrease in account.pdf    Decrease in inventory Source of cash $   440   Decrease in account.pdf
Decrease in inventory Source of cash $   440 Decrease in account.pdfarakalamkah11
 
Diamond is sp3 covalent. It makes for bonds to ne.pdf
                     Diamond is sp3 covalent. It makes for bonds to ne.pdf                     Diamond is sp3 covalent. It makes for bonds to ne.pdf
Diamond is sp3 covalent. It makes for bonds to ne.pdfarakalamkah11
 
Too low. If you do not dry the sodium thiosulfate.pdf
                     Too low. If you do not dry the sodium thiosulfate.pdf                     Too low. If you do not dry the sodium thiosulfate.pdf
Too low. If you do not dry the sodium thiosulfate.pdfarakalamkah11
 
1. A bus is a bunch of wires used to connect multiple subsystems. Bu.pdf
1. A bus is a bunch of wires used to connect multiple subsystems. Bu.pdf1. A bus is a bunch of wires used to connect multiple subsystems. Bu.pdf
1. A bus is a bunch of wires used to connect multiple subsystems. Bu.pdfarakalamkah11
 
1. E) The vapor pressure of a liquid.Increasing attractive intermo.pdf
1. E) The vapor pressure of a liquid.Increasing attractive intermo.pdf1. E) The vapor pressure of a liquid.Increasing attractive intermo.pdf
1. E) The vapor pressure of a liquid.Increasing attractive intermo.pdfarakalamkah11
 
Light is a form of energy that can be released by.pdf
                     Light is a form of energy that can be released by.pdf                     Light is a form of energy that can be released by.pdf
Light is a form of energy that can be released by.pdfarakalamkah11
 
1) Presence of jaws with paired fins in fish helps to feed them. Fin.pdf
1) Presence of jaws with paired fins in fish helps to feed them. Fin.pdf1) Presence of jaws with paired fins in fish helps to feed them. Fin.pdf
1) Presence of jaws with paired fins in fish helps to feed them. Fin.pdfarakalamkah11
 
Youre looking for Ka, the dissociation constant.pdf
                     Youre looking for Ka, the dissociation constant.pdf                     Youre looking for Ka, the dissociation constant.pdf
Youre looking for Ka, the dissociation constant.pdfarakalamkah11
 
Okay so dipole-dipole interactions would occur be.pdf
                     Okay so dipole-dipole interactions would occur be.pdf                     Okay so dipole-dipole interactions would occur be.pdf
Okay so dipole-dipole interactions would occur be.pdfarakalamkah11
 
remote operating system installationRemote Installation Services (.pdf
remote operating system installationRemote Installation Services (.pdfremote operating system installationRemote Installation Services (.pdf
remote operating system installationRemote Installation Services (.pdfarakalamkah11
 
Title of this process is The Project Life Cycle (Phases)The pr.pdf
Title of this process is The Project Life Cycle (Phases)The pr.pdfTitle of this process is The Project Life Cycle (Phases)The pr.pdf
Title of this process is The Project Life Cycle (Phases)The pr.pdfarakalamkah11
 
The answer is A) Pol II, with twelve subunits on its own, is capable.pdf
The answer is A) Pol II, with twelve subunits on its own, is capable.pdfThe answer is A) Pol II, with twelve subunits on its own, is capable.pdf
The answer is A) Pol II, with twelve subunits on its own, is capable.pdfarakalamkah11
 
solutionA=  1    1    0    4    3    1    2    0 .pdf
solutionA=  1    1    0    4    3    1    2    0 .pdfsolutionA=  1    1    0    4    3    1    2    0 .pdf
solutionA=  1    1    0    4    3    1    2    0 .pdfarakalamkah11
 
Q1). Gene therapy is an experimental approach to treat the disease b.pdf
Q1). Gene therapy is an experimental approach to treat the disease b.pdfQ1). Gene therapy is an experimental approach to treat the disease b.pdf
Q1). Gene therapy is an experimental approach to treat the disease b.pdfarakalamkah11
 
Solution Three modes of DNA replication 1) Semi conservative.pdf
Solution Three modes of DNA replication 1) Semi conservative.pdfSolution Three modes of DNA replication 1) Semi conservative.pdf
Solution Three modes of DNA replication 1) Semi conservative.pdfarakalamkah11
 
package s3; Copy paste this Java Template and save it as Emer.pdf
package s3;  Copy paste this Java Template and save it as Emer.pdfpackage s3;  Copy paste this Java Template and save it as Emer.pdf
package s3; Copy paste this Java Template and save it as Emer.pdfarakalamkah11
 
Our body is having two line defence system against pathogens.Pathoge.pdf
Our body is having two line defence system against pathogens.Pathoge.pdfOur body is having two line defence system against pathogens.Pathoge.pdf
Our body is having two line defence system against pathogens.Pathoge.pdfarakalamkah11
 
Once neurons are produced, they migrate and modify to form six layer.pdf
Once neurons are produced, they migrate and modify to form six layer.pdfOnce neurons are produced, they migrate and modify to form six layer.pdf
Once neurons are produced, they migrate and modify to form six layer.pdfarakalamkah11
 
PDU is called Protocol Data Unit.It consists of user data and protoc.pdf
PDU is called Protocol Data Unit.It consists of user data and protoc.pdfPDU is called Protocol Data Unit.It consists of user data and protoc.pdf
PDU is called Protocol Data Unit.It consists of user data and protoc.pdfarakalamkah11
 

More from arakalamkah11 (20)

Particulars $Amount Direct materials 64452 Direct Labour (1332.pdf
    Particulars $Amount   Direct materials 64452   Direct Labour (1332.pdf    Particulars $Amount   Direct materials 64452   Direct Labour (1332.pdf
Particulars $Amount Direct materials 64452 Direct Labour (1332.pdf
 
Decrease in inventory Source of cash $   440 Decrease in account.pdf
    Decrease in inventory Source of cash $   440   Decrease in account.pdf    Decrease in inventory Source of cash $   440   Decrease in account.pdf
Decrease in inventory Source of cash $   440 Decrease in account.pdf
 
Diamond is sp3 covalent. It makes for bonds to ne.pdf
                     Diamond is sp3 covalent. It makes for bonds to ne.pdf                     Diamond is sp3 covalent. It makes for bonds to ne.pdf
Diamond is sp3 covalent. It makes for bonds to ne.pdf
 
Too low. If you do not dry the sodium thiosulfate.pdf
                     Too low. If you do not dry the sodium thiosulfate.pdf                     Too low. If you do not dry the sodium thiosulfate.pdf
Too low. If you do not dry the sodium thiosulfate.pdf
 
1. A bus is a bunch of wires used to connect multiple subsystems. Bu.pdf
1. A bus is a bunch of wires used to connect multiple subsystems. Bu.pdf1. A bus is a bunch of wires used to connect multiple subsystems. Bu.pdf
1. A bus is a bunch of wires used to connect multiple subsystems. Bu.pdf
 
1. E) The vapor pressure of a liquid.Increasing attractive intermo.pdf
1. E) The vapor pressure of a liquid.Increasing attractive intermo.pdf1. E) The vapor pressure of a liquid.Increasing attractive intermo.pdf
1. E) The vapor pressure of a liquid.Increasing attractive intermo.pdf
 
Light is a form of energy that can be released by.pdf
                     Light is a form of energy that can be released by.pdf                     Light is a form of energy that can be released by.pdf
Light is a form of energy that can be released by.pdf
 
1) Presence of jaws with paired fins in fish helps to feed them. Fin.pdf
1) Presence of jaws with paired fins in fish helps to feed them. Fin.pdf1) Presence of jaws with paired fins in fish helps to feed them. Fin.pdf
1) Presence of jaws with paired fins in fish helps to feed them. Fin.pdf
 
Youre looking for Ka, the dissociation constant.pdf
                     Youre looking for Ka, the dissociation constant.pdf                     Youre looking for Ka, the dissociation constant.pdf
Youre looking for Ka, the dissociation constant.pdf
 
Okay so dipole-dipole interactions would occur be.pdf
                     Okay so dipole-dipole interactions would occur be.pdf                     Okay so dipole-dipole interactions would occur be.pdf
Okay so dipole-dipole interactions would occur be.pdf
 
remote operating system installationRemote Installation Services (.pdf
remote operating system installationRemote Installation Services (.pdfremote operating system installationRemote Installation Services (.pdf
remote operating system installationRemote Installation Services (.pdf
 
Title of this process is The Project Life Cycle (Phases)The pr.pdf
Title of this process is The Project Life Cycle (Phases)The pr.pdfTitle of this process is The Project Life Cycle (Phases)The pr.pdf
Title of this process is The Project Life Cycle (Phases)The pr.pdf
 
The answer is A) Pol II, with twelve subunits on its own, is capable.pdf
The answer is A) Pol II, with twelve subunits on its own, is capable.pdfThe answer is A) Pol II, with twelve subunits on its own, is capable.pdf
The answer is A) Pol II, with twelve subunits on its own, is capable.pdf
 
solutionA=  1    1    0    4    3    1    2    0 .pdf
solutionA=  1    1    0    4    3    1    2    0 .pdfsolutionA=  1    1    0    4    3    1    2    0 .pdf
solutionA=  1    1    0    4    3    1    2    0 .pdf
 
Q1). Gene therapy is an experimental approach to treat the disease b.pdf
Q1). Gene therapy is an experimental approach to treat the disease b.pdfQ1). Gene therapy is an experimental approach to treat the disease b.pdf
Q1). Gene therapy is an experimental approach to treat the disease b.pdf
 
Solution Three modes of DNA replication 1) Semi conservative.pdf
Solution Three modes of DNA replication 1) Semi conservative.pdfSolution Three modes of DNA replication 1) Semi conservative.pdf
Solution Three modes of DNA replication 1) Semi conservative.pdf
 
package s3; Copy paste this Java Template and save it as Emer.pdf
package s3;  Copy paste this Java Template and save it as Emer.pdfpackage s3;  Copy paste this Java Template and save it as Emer.pdf
package s3; Copy paste this Java Template and save it as Emer.pdf
 
Our body is having two line defence system against pathogens.Pathoge.pdf
Our body is having two line defence system against pathogens.Pathoge.pdfOur body is having two line defence system against pathogens.Pathoge.pdf
Our body is having two line defence system against pathogens.Pathoge.pdf
 
Once neurons are produced, they migrate and modify to form six layer.pdf
Once neurons are produced, they migrate and modify to form six layer.pdfOnce neurons are produced, they migrate and modify to form six layer.pdf
Once neurons are produced, they migrate and modify to form six layer.pdf
 
PDU is called Protocol Data Unit.It consists of user data and protoc.pdf
PDU is called Protocol Data Unit.It consists of user data and protoc.pdfPDU is called Protocol Data Unit.It consists of user data and protoc.pdf
PDU is called Protocol Data Unit.It consists of user data and protoc.pdf
 

Recently uploaded

會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文中 央社
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaEADTU
 
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
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnershipsexpandedwebsite
 
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
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfPondicherry University
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFVivekanand Anglo Vedic Academy
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSAnaAcapella
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽中 央社
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptxPoojaSen20
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...Gary Wood
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesAmanpreetKaur157993
 
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
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportDenish Jangid
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code ExamplesPeter Brusilovsky
 
ĐỀ 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
 
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
 

Recently uploaded (20)

會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
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
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
 
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...
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
 
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
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDF
 
Supporting Newcomer Multilingual Learners
Supporting Newcomer  Multilingual LearnersSupporting Newcomer  Multilingual Learners
Supporting Newcomer Multilingual Learners
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptx
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 
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)
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategies
 
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
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
ĐỀ 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...
 
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
 

1. JUnit test for method toString() in SalariedEmployee -import or.pdf

  • 1. 1. JUnit test for method toString() in SalariedEmployee - import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.runners.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class SalariedEmployeeTest { @Test public void testToString(){ String name="name"; double salary=3000; double bonus=1000; SalariedEmployee employee= new SalariedEmployee(name,salary,bonus); employee.toString(); } } 2. JAva program to replace "is" with "was" - import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class StringReplace { public static void main(String[] args) throws IOException { BufferedReader br = null; File file = new File("/My Stuffs/Root/Workspace/TestJava/src/com/test/output.txt"); FileWriter fw = new FileWriter(file.getAbsoluteFile()); BufferedWriter bw = new BufferedWriter(fw); if (!file.exists()) { file.createNewFile(); } try { String sCurrentLine; br = new BufferedReader(new FileReader("/My
  • 2. Stuffs/Root/Workspace/TestJava/src/com/test/testing.txt")); while ((sCurrentLine = br.readLine()) != null) { System.out.println(sCurrentLine); String rep=sCurrentLine.replaceAll(" is "," was "); System.out.println(rep); bw.write(rep); } } catch (IOException e) { e.printStackTrace(); } finally { try { if (br != null)br.close(); if(bw!=null)bw.close(); } catch (IOException ex) { ex.printStackTrace(); } } } } Solution 1. JUnit test for method toString() in SalariedEmployee - import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.runners.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class SalariedEmployeeTest { @Test public void testToString(){ String name="name"; double salary=3000; double bonus=1000; SalariedEmployee employee= new SalariedEmployee(name,salary,bonus); employee.toString();
  • 3. } } 2. JAva program to replace "is" with "was" - import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class StringReplace { public static void main(String[] args) throws IOException { BufferedReader br = null; File file = new File("/My Stuffs/Root/Workspace/TestJava/src/com/test/output.txt"); FileWriter fw = new FileWriter(file.getAbsoluteFile()); BufferedWriter bw = new BufferedWriter(fw); if (!file.exists()) { file.createNewFile(); } try { String sCurrentLine; br = new BufferedReader(new FileReader("/My Stuffs/Root/Workspace/TestJava/src/com/test/testing.txt")); while ((sCurrentLine = br.readLine()) != null) { System.out.println(sCurrentLine); String rep=sCurrentLine.replaceAll(" is "," was "); System.out.println(rep); bw.write(rep); } } catch (IOException e) { e.printStackTrace(); } finally { try { if (br != null)br.close(); if(bw!=null)bw.close(); } catch (IOException ex) { ex.printStackTrace();