SlideShare a Scribd company logo
Java small tests
String s1 = "Hello";
String s3 = new String("Hello");
System.out.println("s1==s3 -> " + (s1==s3));
String s1 = "Hello";
String s3 = new String("Hello");
System.out.println("s1==s3 -> " + (s1==s3));
s1==s3 -> false
String s1 = "Hello";
String s3 = new String("Hello");
System.out.println("s1.equals(s3) -> " +
s1.equals(s3));
String s1 = "Hello";
String s3 = new String("Hello");
System.out.println("s1.equals(s3) -> " +
s1.equals(s3));
s1.equals(s3) -> true
String s1 = "Hello";
String s2 = "Hello";
System.out.println("s1==s2 -> " + (s1==s2));
String s1 = "Hello";
String s2 = "Hello";
System.out.println("s1==s2 -> " + (s1==s2));
s1==s2 -> true
class Test
{
protected void finalize()
{
System.out.println("finalize!!!");
}
}
void test_finalize()
{
for(int i=0;i<5;++i)
{
Test a = new Test();
System.out.println("i = " + i);
}
System.gc();
}
class Test
{
protected void finalize()
{
System.out.println("finalize!!!");
}
}
void test_finalize()
{
for(int i=0;i<5;++i)
{
Test a = new Test();
System.out.println("i = " + i);
}
System.gc();
}
i = 0
i = 1
i = 2
i = 3
i = 4
๏ฌnalize!!!
๏ฌnalize!!!
๏ฌnalize!!!
๏ฌnalize!!!
๏ฌnalize!!!
class Test
{
protected void finalize()
{
System.out.println("Exit");
System.exit(0);
}
}
void test_finalize()
{
for(int i=0;i<500000;++i)
{
Test a = new Test();
System.out.println("i = " + i);
}
System.gc();
}
class Test
{
protected void finalize()
{
System.out.println("Exit");
System.exit(0);
}
}
void test_finalize()
{
for(int i=0;i<500000;++i)
{
Test a = new Test();
System.out.println("i = " + i);
}
System.gc();
}
โ€ฆ
i = 63624
i = 63625
i = 63626
i = 63627
i = 63628
i = 63629
Exit
i = 63630
i = 63631
i = 63632
i = 63633
i = 63634
i = 63635
i = 63636
i = 63637
i = 63638

More Related Content

Similar to Java Small Tests

Learn Java Part 6
Learn Java Part 6Learn Java Part 6
Learn Java Part 6
Gurpreet singh
ย 
Java String Handling
Java String HandlingJava String Handling
Java String Handling
Infoviaan Technologies
ย 
Training Java - Lesson3
Training Java - Lesson3Training Java - Lesson3
Training Java - Lesson3
mittoq
ย 
import java.util.ArrayList; import java.util.Scanner;public clas.pdf
import java.util.ArrayList; import java.util.Scanner;public clas.pdfimport java.util.ArrayList; import java.util.Scanner;public clas.pdf
import java.util.ArrayList; import java.util.Scanner;public clas.pdf
shettysachin2005
ย 
QA Auotmation Java programs,theory
QA Auotmation Java programs,theory QA Auotmation Java programs,theory
QA Auotmation Java programs,theory
archana singh
ย 
Strings CPU GTU
Strings CPU GTUStrings CPU GTU
Strings CPU GTU
Maharshi Dave
ย 
07. Java Array, Set and Maps
07.  Java Array, Set and Maps07.  Java Array, Set and Maps
07. Java Array, Set and Maps
Intro C# Book
ย 
Scala == Effective Java
Scala == Effective JavaScala == Effective Java
Scala == Effective Java
Scalac
ย 
JavaScript - Chapter 10 - Strings and Arrays
 JavaScript - Chapter 10 - Strings and Arrays JavaScript - Chapter 10 - Strings and Arrays
JavaScript - Chapter 10 - Strings and Arrays
WebStackAcademy
ย 

Similar to Java Small Tests (9)

Learn Java Part 6
Learn Java Part 6Learn Java Part 6
Learn Java Part 6
ย 
Java String Handling
Java String HandlingJava String Handling
Java String Handling
ย 
Training Java - Lesson3
Training Java - Lesson3Training Java - Lesson3
Training Java - Lesson3
ย 
import java.util.ArrayList; import java.util.Scanner;public clas.pdf
import java.util.ArrayList; import java.util.Scanner;public clas.pdfimport java.util.ArrayList; import java.util.Scanner;public clas.pdf
import java.util.ArrayList; import java.util.Scanner;public clas.pdf
ย 
QA Auotmation Java programs,theory
QA Auotmation Java programs,theory QA Auotmation Java programs,theory
QA Auotmation Java programs,theory
ย 
Strings CPU GTU
Strings CPU GTUStrings CPU GTU
Strings CPU GTU
ย 
07. Java Array, Set and Maps
07.  Java Array, Set and Maps07.  Java Array, Set and Maps
07. Java Array, Set and Maps
ย 
Scala == Effective Java
Scala == Effective JavaScala == Effective Java
Scala == Effective Java
ย 
JavaScript - Chapter 10 - Strings and Arrays
 JavaScript - Chapter 10 - Strings and Arrays JavaScript - Chapter 10 - Strings and Arrays
JavaScript - Chapter 10 - Strings and Arrays
ย 

More from Maksym Davydov

Firebase overview
Firebase overviewFirebase overview
Firebase overview
Maksym Davydov
ย 
Microsoft mobile services
Microsoft mobile servicesMicrosoft mobile services
Microsoft mobile services
Maksym Davydov
ย 
Design of mobile apps
Design of mobile appsDesign of mobile apps
Design of mobile apps
Maksym Davydov
ย 
Mobile app design feature development
Mobile app design feature developmentMobile app design feature development
Mobile app design feature development
Maksym Davydov
ย 
Android mix Java and C++
Android mix Java and C++Android mix Java and C++
Android mix Java and C++
Maksym Davydov
ย 
Android animations
Android animationsAndroid animations
Android animations
Maksym Davydov
ย 
Handler declaration in layout
Handler declaration in layoutHandler declaration in layout
Handler declaration in layout
Maksym Davydov
ย 
Android Networking
Android NetworkingAndroid Networking
Android Networking
Maksym Davydov
ย 
Android Storage
Android StorageAndroid Storage
Android Storage
Maksym Davydov
ย 
Interface Programming Android
Interface Programming AndroidInterface Programming Android
Interface Programming Android
Maksym Davydov
ย 
Android Programming Intro
Android Programming IntroAndroid Programming Intro
Android Programming Intro
Maksym Davydov
ย 
Lecture 02 Mobile hardware
Lecture 02 Mobile hardwareLecture 02 Mobile hardware
Lecture 02 Mobile hardware
Maksym Davydov
ย 
Lecture 01 Mobile operating systems
Lecture 01 Mobile operating systemsLecture 01 Mobile operating systems
Lecture 01 Mobile operating systems
Maksym Davydov
ย 
Lecture 13 Local Optimization on Mobile Devices
Lecture 13 Local Optimization on Mobile DevicesLecture 13 Local Optimization on Mobile Devices
Lecture 13 Local Optimization on Mobile Devices
Maksym Davydov
ย 
Lecture 12. iOS and Android Animations
Lecture 12. iOS and Android AnimationsLecture 12. iOS and Android Animations
Lecture 12. iOS and Android Animations
Maksym Davydov
ย 
Lecture 11. Microsoft mobile services
Lecture 11. Microsoft mobile servicesLecture 11. Microsoft mobile services
Lecture 11. Microsoft mobile services
Maksym Davydov
ย 
Lecture 11 Firebase overview
Lecture 11 Firebase overviewLecture 11 Firebase overview
Lecture 11 Firebase overview
Maksym Davydov
ย 
Lecture 10 Networking on Mobile Devices
Lecture 10 Networking on Mobile DevicesLecture 10 Networking on Mobile Devices
Lecture 10 Networking on Mobile Devices
Maksym Davydov
ย 
Lecture 09 Android Storage
Lecture 09 Android StorageLecture 09 Android Storage
Lecture 09 Android Storage
Maksym Davydov
ย 
Lecture 08 Xamarin
Lecture 08 XamarinLecture 08 Xamarin
Lecture 08 Xamarin
Maksym Davydov
ย 

More from Maksym Davydov (20)

Firebase overview
Firebase overviewFirebase overview
Firebase overview
ย 
Microsoft mobile services
Microsoft mobile servicesMicrosoft mobile services
Microsoft mobile services
ย 
Design of mobile apps
Design of mobile appsDesign of mobile apps
Design of mobile apps
ย 
Mobile app design feature development
Mobile app design feature developmentMobile app design feature development
Mobile app design feature development
ย 
Android mix Java and C++
Android mix Java and C++Android mix Java and C++
Android mix Java and C++
ย 
Android animations
Android animationsAndroid animations
Android animations
ย 
Handler declaration in layout
Handler declaration in layoutHandler declaration in layout
Handler declaration in layout
ย 
Android Networking
Android NetworkingAndroid Networking
Android Networking
ย 
Android Storage
Android StorageAndroid Storage
Android Storage
ย 
Interface Programming Android
Interface Programming AndroidInterface Programming Android
Interface Programming Android
ย 
Android Programming Intro
Android Programming IntroAndroid Programming Intro
Android Programming Intro
ย 
Lecture 02 Mobile hardware
Lecture 02 Mobile hardwareLecture 02 Mobile hardware
Lecture 02 Mobile hardware
ย 
Lecture 01 Mobile operating systems
Lecture 01 Mobile operating systemsLecture 01 Mobile operating systems
Lecture 01 Mobile operating systems
ย 
Lecture 13 Local Optimization on Mobile Devices
Lecture 13 Local Optimization on Mobile DevicesLecture 13 Local Optimization on Mobile Devices
Lecture 13 Local Optimization on Mobile Devices
ย 
Lecture 12. iOS and Android Animations
Lecture 12. iOS and Android AnimationsLecture 12. iOS and Android Animations
Lecture 12. iOS and Android Animations
ย 
Lecture 11. Microsoft mobile services
Lecture 11. Microsoft mobile servicesLecture 11. Microsoft mobile services
Lecture 11. Microsoft mobile services
ย 
Lecture 11 Firebase overview
Lecture 11 Firebase overviewLecture 11 Firebase overview
Lecture 11 Firebase overview
ย 
Lecture 10 Networking on Mobile Devices
Lecture 10 Networking on Mobile DevicesLecture 10 Networking on Mobile Devices
Lecture 10 Networking on Mobile Devices
ย 
Lecture 09 Android Storage
Lecture 09 Android StorageLecture 09 Android Storage
Lecture 09 Android Storage
ย 
Lecture 08 Xamarin
Lecture 08 XamarinLecture 08 Xamarin
Lecture 08 Xamarin
ย 

Recently uploaded

A Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two HeartsA Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two Hearts
Steve Thomason
ย 
How to Manage Reception Report in Odoo 17
How to Manage Reception Report in Odoo 17How to Manage Reception Report in Odoo 17
How to Manage Reception Report in Odoo 17
Celine George
ย 
Data Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsxData Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsx
Prof. Dr. K. Adisesha
ย 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
Jyoti Chand
ย 
skeleton System.pdf (skeleton system wow)
skeleton System.pdf (skeleton system wow)skeleton System.pdf (skeleton system wow)
skeleton System.pdf (skeleton system wow)
Mohammad Al-Dhahabi
ย 
SWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptxSWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptx
zuzanka
ย 
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
indexPub
ย 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
Himanshu Rai
ย 
HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
deepaannamalai16
ย 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
deepaannamalai16
ย 
ู…ุตุญู ุงู„ู‚ุฑุงุกุงุช ุงู„ุนุดุฑ ุฃุนุฏ ุฃุญุฑู ุงู„ุฎู„ุงู ุณู…ูŠุฑ ุจุณูŠูˆู†ูŠ.pdf
ู…ุตุญู ุงู„ู‚ุฑุงุกุงุช ุงู„ุนุดุฑ   ุฃุนุฏ ุฃุญุฑู ุงู„ุฎู„ุงู ุณู…ูŠุฑ ุจุณูŠูˆู†ูŠ.pdfู…ุตุญู ุงู„ู‚ุฑุงุกุงุช ุงู„ุนุดุฑ   ุฃุนุฏ ุฃุญุฑู ุงู„ุฎู„ุงู ุณู…ูŠุฑ ุจุณูŠูˆู†ูŠ.pdf
ู…ุตุญู ุงู„ู‚ุฑุงุกุงุช ุงู„ุนุดุฑ ุฃุนุฏ ุฃุญุฑู ุงู„ุฎู„ุงู ุณู…ูŠุฑ ุจุณูŠูˆู†ูŠ.pdf
ุณู…ูŠุฑ ุจุณูŠูˆู†ูŠ
ย 
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
EduSkills OECD
ย 
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdfREASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
giancarloi8888
ย 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
MJDuyan
ย 
NIPER 2024 MEMORY BASED QUESTIONS.ANSWERS TO NIPER 2024 QUESTIONS.NIPER JEE 2...
NIPER 2024 MEMORY BASED QUESTIONS.ANSWERS TO NIPER 2024 QUESTIONS.NIPER JEE 2...NIPER 2024 MEMORY BASED QUESTIONS.ANSWERS TO NIPER 2024 QUESTIONS.NIPER JEE 2...
NIPER 2024 MEMORY BASED QUESTIONS.ANSWERS TO NIPER 2024 QUESTIONS.NIPER JEE 2...
Payaamvohra1
ย 
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptxCapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapitolTechU
ย 
Prรฉsentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Prรฉsentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrรฉsentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Prรฉsentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
siemaillard
ย 
Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
PsychoTech Services
ย 
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptxNEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
iammrhaywood
ย 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
zuzanka
ย 

Recently uploaded (20)

A Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two HeartsA Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two Hearts
ย 
How to Manage Reception Report in Odoo 17
How to Manage Reception Report in Odoo 17How to Manage Reception Report in Odoo 17
How to Manage Reception Report in Odoo 17
ย 
Data Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsxData Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsx
ย 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
ย 
skeleton System.pdf (skeleton system wow)
skeleton System.pdf (skeleton system wow)skeleton System.pdf (skeleton system wow)
skeleton System.pdf (skeleton system wow)
ย 
SWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptxSWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptx
ย 
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
ย 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
ย 
HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
ย 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
ย 
ู…ุตุญู ุงู„ู‚ุฑุงุกุงุช ุงู„ุนุดุฑ ุฃุนุฏ ุฃุญุฑู ุงู„ุฎู„ุงู ุณู…ูŠุฑ ุจุณูŠูˆู†ูŠ.pdf
ู…ุตุญู ุงู„ู‚ุฑุงุกุงุช ุงู„ุนุดุฑ   ุฃุนุฏ ุฃุญุฑู ุงู„ุฎู„ุงู ุณู…ูŠุฑ ุจุณูŠูˆู†ูŠ.pdfู…ุตุญู ุงู„ู‚ุฑุงุกุงุช ุงู„ุนุดุฑ   ุฃุนุฏ ุฃุญุฑู ุงู„ุฎู„ุงู ุณู…ูŠุฑ ุจุณูŠูˆู†ูŠ.pdf
ู…ุตุญู ุงู„ู‚ุฑุงุกุงุช ุงู„ุนุดุฑ ุฃุนุฏ ุฃุญุฑู ุงู„ุฎู„ุงู ุณู…ูŠุฑ ุจุณูŠูˆู†ูŠ.pdf
ย 
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
ย 
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdfREASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
ย 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
ย 
NIPER 2024 MEMORY BASED QUESTIONS.ANSWERS TO NIPER 2024 QUESTIONS.NIPER JEE 2...
NIPER 2024 MEMORY BASED QUESTIONS.ANSWERS TO NIPER 2024 QUESTIONS.NIPER JEE 2...NIPER 2024 MEMORY BASED QUESTIONS.ANSWERS TO NIPER 2024 QUESTIONS.NIPER JEE 2...
NIPER 2024 MEMORY BASED QUESTIONS.ANSWERS TO NIPER 2024 QUESTIONS.NIPER JEE 2...
ย 
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptxCapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
ย 
Prรฉsentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Prรฉsentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrรฉsentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Prรฉsentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
ย 
Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
ย 
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptxNEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
ย 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
ย 

Java Small Tests

  • 2. String s1 = "Hello"; String s3 = new String("Hello"); System.out.println("s1==s3 -> " + (s1==s3));
  • 3. String s1 = "Hello"; String s3 = new String("Hello"); System.out.println("s1==s3 -> " + (s1==s3)); s1==s3 -> false
  • 4. String s1 = "Hello"; String s3 = new String("Hello"); System.out.println("s1.equals(s3) -> " + s1.equals(s3));
  • 5. String s1 = "Hello"; String s3 = new String("Hello"); System.out.println("s1.equals(s3) -> " + s1.equals(s3)); s1.equals(s3) -> true
  • 6. String s1 = "Hello"; String s2 = "Hello"; System.out.println("s1==s2 -> " + (s1==s2));
  • 7. String s1 = "Hello"; String s2 = "Hello"; System.out.println("s1==s2 -> " + (s1==s2)); s1==s2 -> true
  • 8. class Test { protected void finalize() { System.out.println("finalize!!!"); } } void test_finalize() { for(int i=0;i<5;++i) { Test a = new Test(); System.out.println("i = " + i); } System.gc(); }
  • 9. class Test { protected void finalize() { System.out.println("finalize!!!"); } } void test_finalize() { for(int i=0;i<5;++i) { Test a = new Test(); System.out.println("i = " + i); } System.gc(); } i = 0 i = 1 i = 2 i = 3 i = 4 ๏ฌnalize!!! ๏ฌnalize!!! ๏ฌnalize!!! ๏ฌnalize!!! ๏ฌnalize!!!
  • 10. class Test { protected void finalize() { System.out.println("Exit"); System.exit(0); } } void test_finalize() { for(int i=0;i<500000;++i) { Test a = new Test(); System.out.println("i = " + i); } System.gc(); }
  • 11. class Test { protected void finalize() { System.out.println("Exit"); System.exit(0); } } void test_finalize() { for(int i=0;i<500000;++i) { Test a = new Test(); System.out.println("i = " + i); } System.gc(); } โ€ฆ i = 63624 i = 63625 i = 63626 i = 63627 i = 63628 i = 63629 Exit i = 63630 i = 63631 i = 63632 i = 63633 i = 63634 i = 63635 i = 63636 i = 63637 i = 63638