SlideShare a Scribd company logo
1 of 2
Download to read offline
What is the output of running class GenericMethodDemo of the following code?
public class GenericMethodDemo {
public static void main(String[] args ) {
Integer[] integers = {1, 2, 3, 4, 5};
String[] strings = {"London", "Paris", "Dhaka",
"Austin", "Sydney"};
GenericMethodDemo.print(integers);
GenericMethodDemo.print(strings);
}
public static void print(E[] list) {
for (int i = 0; i < list.length; i++){
System.out.print(list[i] + " ");
}
System.out.println();
}
}
What is the output of running class GenericMethodDemo of the following code?
public class GenericMethodDemo {
public static void main(String[] args ) {
Integer[] integers = {1, 2, 3, 4, 5};
String[] strings = {"London", "Paris", "Dhaka",
"Austin", "Sydney"};
GenericMethodDemo.print(integers);
GenericMethodDemo.print(strings);
}
public static void print(E[] list) {
for (int i = 0; i < list.length; i++){
System.out.print(list[i] + " ");
}
System.out.println();
}
}
Solution
output 1 :
London
Paris
Dhaka
Austin
Sydney
The above is the output of hte above program

More Related Content

Similar to What is the output of running class GenericMethodDemo of the followi.pdf

[WELC] 21. I’m Changing the Same Code All Over the Place
[WELC] 21. I’m Changing the Same Code All Over the Place[WELC] 21. I’m Changing the Same Code All Over the Place
[WELC] 21. I’m Changing the Same Code All Over the Place
종빈 오
 
Computer science-2010-cbse-question-paper
Computer science-2010-cbse-question-paperComputer science-2010-cbse-question-paper
Computer science-2010-cbse-question-paper
Deepak Singh
 
KOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
KOLEJ KOMUNITI - Sijil Aplikasi Perisian KomputerKOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
KOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
Aiman Hud
 
C# 6.0 - April 2014 preview
C# 6.0 - April 2014 previewC# 6.0 - April 2014 preview
C# 6.0 - April 2014 preview
Paulo Morgado
 

Similar to What is the output of running class GenericMethodDemo of the followi.pdf (20)

Java arrays
Java    arraysJava    arrays
Java arrays
 
20.1 Java working with abstraction
20.1 Java working with abstraction20.1 Java working with abstraction
20.1 Java working with abstraction
 
Java practical
Java practicalJava practical
Java practical
 
PRACTICAL COMPUTING
PRACTICAL COMPUTINGPRACTICAL COMPUTING
PRACTICAL COMPUTING
 
Java Foundations: Methods
Java Foundations: MethodsJava Foundations: Methods
Java Foundations: Methods
 
Computer java programs
Computer java programsComputer java programs
Computer java programs
 
Review Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdfReview Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdf
 
Parameters
ParametersParameters
Parameters
 
Operators
OperatorsOperators
Operators
 
Trace the following part of codes step by step- Show exactly what it w.docx
Trace the following part of codes step by step- Show exactly what it w.docxTrace the following part of codes step by step- Show exactly what it w.docx
Trace the following part of codes step by step- Show exactly what it w.docx
 
[WELC] 21. I’m Changing the Same Code All Over the Place
[WELC] 21. I’m Changing the Same Code All Over the Place[WELC] 21. I’m Changing the Same Code All Over the Place
[WELC] 21. I’m Changing the Same Code All Over the Place
 
Ann
AnnAnn
Ann
 
final year project center in Coimbatore
final year project center in Coimbatorefinal year project center in Coimbatore
final year project center in Coimbatore
 
#include #include #include using namespace std- class ErrorHandler(.docx
#include  #include  #include  using namespace std- class ErrorHandler(.docx#include  #include  #include  using namespace std- class ErrorHandler(.docx
#include #include #include using namespace std- class ErrorHandler(.docx
 
06slide.ppt
06slide.ppt06slide.ppt
06slide.ppt
 
Computer science-2010-cbse-question-paper
Computer science-2010-cbse-question-paperComputer science-2010-cbse-question-paper
Computer science-2010-cbse-question-paper
 
Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...
Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...
Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...
 
KOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
KOLEJ KOMUNITI - Sijil Aplikasi Perisian KomputerKOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
KOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
 
Generics
GenericsGenerics
Generics
 
C# 6.0 - April 2014 preview
C# 6.0 - April 2014 previewC# 6.0 - April 2014 preview
C# 6.0 - April 2014 preview
 

More from bhim1213

In 1998, Congress passed legislation concerning shifting the burden .pdf
In 1998, Congress passed legislation concerning shifting the burden .pdfIn 1998, Congress passed legislation concerning shifting the burden .pdf
In 1998, Congress passed legislation concerning shifting the burden .pdf
bhim1213
 
From your own words not copy past from internet please Talked about.pdf
From your own words not copy past from internet please Talked about.pdfFrom your own words not copy past from internet please Talked about.pdf
From your own words not copy past from internet please Talked about.pdf
bhim1213
 
Define toxic shock syndrome (TSS) impetigo MRSASolutionAnswer.pdf
Define toxic shock syndrome (TSS) impetigo MRSASolutionAnswer.pdfDefine toxic shock syndrome (TSS) impetigo MRSASolutionAnswer.pdf
Define toxic shock syndrome (TSS) impetigo MRSASolutionAnswer.pdf
bhim1213
 
Biochemistry homework Focus concept ripening fruit and the activity.pdf
Biochemistry homework Focus concept ripening fruit and the activity.pdfBiochemistry homework Focus concept ripening fruit and the activity.pdf
Biochemistry homework Focus concept ripening fruit and the activity.pdf
bhim1213
 
What is the relationship of the epithelium of the epidermis to the co.pdf
What is the relationship of the epithelium of the epidermis to the co.pdfWhat is the relationship of the epithelium of the epidermis to the co.pdf
What is the relationship of the epithelium of the epidermis to the co.pdf
bhim1213
 
What do you think are the roles of professional societies in contemp.pdf
What do you think are the roles of professional societies in contemp.pdfWhat do you think are the roles of professional societies in contemp.pdf
What do you think are the roles of professional societies in contemp.pdf
bhim1213
 

More from bhim1213 (20)

In 1998, Congress passed legislation concerning shifting the burden .pdf
In 1998, Congress passed legislation concerning shifting the burden .pdfIn 1998, Congress passed legislation concerning shifting the burden .pdf
In 1998, Congress passed legislation concerning shifting the burden .pdf
 
If A denotes some event, what does A denote If P(A)equals=0.997, wh.pdf
If A denotes some event, what does A denote If P(A)equals=0.997, wh.pdfIf A denotes some event, what does A denote If P(A)equals=0.997, wh.pdf
If A denotes some event, what does A denote If P(A)equals=0.997, wh.pdf
 
How do neutrophils find and get to an infectionSolutionNeutro.pdf
How do neutrophils find and get to an infectionSolutionNeutro.pdfHow do neutrophils find and get to an infectionSolutionNeutro.pdf
How do neutrophils find and get to an infectionSolutionNeutro.pdf
 
How many times will the following code print Welcome to Java in.pdf
How many times will the following code print Welcome to Java  in.pdfHow many times will the following code print Welcome to Java  in.pdf
How many times will the following code print Welcome to Java in.pdf
 
From your own words not copy past from internet please Talked about.pdf
From your own words not copy past from internet please Talked about.pdfFrom your own words not copy past from internet please Talked about.pdf
From your own words not copy past from internet please Talked about.pdf
 
Forms an important part of the subunits of the ribosome. The _ are sp.pdf
Forms an important part of the subunits of the ribosome. The _ are sp.pdfForms an important part of the subunits of the ribosome. The _ are sp.pdf
Forms an important part of the subunits of the ribosome. The _ are sp.pdf
 
During DNA replication, a series of steps are required to ensure tha.pdf
During DNA replication, a series of steps are required to ensure tha.pdfDuring DNA replication, a series of steps are required to ensure tha.pdf
During DNA replication, a series of steps are required to ensure tha.pdf
 
Disease X occurs when someone has the xx genotype. However, only 20 .pdf
Disease X occurs when someone has the xx genotype. However, only 20 .pdfDisease X occurs when someone has the xx genotype. However, only 20 .pdf
Disease X occurs when someone has the xx genotype. However, only 20 .pdf
 
Darwins Theory had five main tenets (or components), what are they.pdf
Darwins Theory had five main tenets (or components), what are they.pdfDarwins Theory had five main tenets (or components), what are they.pdf
Darwins Theory had five main tenets (or components), what are they.pdf
 
Define toxic shock syndrome (TSS) impetigo MRSASolutionAnswer.pdf
Define toxic shock syndrome (TSS) impetigo MRSASolutionAnswer.pdfDefine toxic shock syndrome (TSS) impetigo MRSASolutionAnswer.pdf
Define toxic shock syndrome (TSS) impetigo MRSASolutionAnswer.pdf
 
A system was set up in parallel with two components, A and B. The pr.pdf
A system was set up in parallel with two components, A and B. The pr.pdfA system was set up in parallel with two components, A and B. The pr.pdf
A system was set up in parallel with two components, A and B. The pr.pdf
 
All content is made permanent for future use. All content will be lo.pdf
All content is made permanent for future use.  All content will be lo.pdfAll content is made permanent for future use.  All content will be lo.pdf
All content is made permanent for future use. All content will be lo.pdf
 
a. A waitress is serving 5 people at a table. She has the 5 dishes t.pdf
a. A waitress is serving 5 people at a table. She has the 5 dishes t.pdfa. A waitress is serving 5 people at a table. She has the 5 dishes t.pdf
a. A waitress is serving 5 people at a table. She has the 5 dishes t.pdf
 
Biochemistry homework Focus concept ripening fruit and the activity.pdf
Biochemistry homework Focus concept ripening fruit and the activity.pdfBiochemistry homework Focus concept ripening fruit and the activity.pdf
Biochemistry homework Focus concept ripening fruit and the activity.pdf
 
A process that has its representative PCB in a device queue is in th.pdf
A process that has its representative PCB in a device queue is in th.pdfA process that has its representative PCB in a device queue is in th.pdf
A process that has its representative PCB in a device queue is in th.pdf
 
Which of the following statements is (are) trueI Cash flow is a.pdf
Which of the following statements is (are) trueI  Cash flow is a.pdfWhich of the following statements is (are) trueI  Cash flow is a.pdf
Which of the following statements is (are) trueI Cash flow is a.pdf
 
What is the relationship of the epithelium of the epidermis to the co.pdf
What is the relationship of the epithelium of the epidermis to the co.pdfWhat is the relationship of the epithelium of the epidermis to the co.pdf
What is the relationship of the epithelium of the epidermis to the co.pdf
 
What is a linked listWhat is a linked lists general syntaxCan .pdf
What is a linked listWhat is a linked lists general syntaxCan .pdfWhat is a linked listWhat is a linked lists general syntaxCan .pdf
What is a linked listWhat is a linked lists general syntaxCan .pdf
 
What do you think are the roles of professional societies in contemp.pdf
What do you think are the roles of professional societies in contemp.pdfWhat do you think are the roles of professional societies in contemp.pdf
What do you think are the roles of professional societies in contemp.pdf
 
What is the compensation depth for phytoplankton How does it differ .pdf
What is the compensation depth for phytoplankton How does it differ .pdfWhat is the compensation depth for phytoplankton How does it differ .pdf
What is the compensation depth for phytoplankton How does it differ .pdf
 

Recently uploaded

會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
中 央社
 
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
AnaAcapella
 
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
 
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MysoreMuleSoftMeetup
 

Recently uploaded (20)

會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
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...
 
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
 
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)
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
 
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...
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical Principles
 
Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"
 
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"
 
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...
 
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
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management
 
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
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
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
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...
 

What is the output of running class GenericMethodDemo of the followi.pdf

  • 1. What is the output of running class GenericMethodDemo of the following code? public class GenericMethodDemo { public static void main(String[] args ) { Integer[] integers = {1, 2, 3, 4, 5}; String[] strings = {"London", "Paris", "Dhaka", "Austin", "Sydney"}; GenericMethodDemo.print(integers); GenericMethodDemo.print(strings); } public static void print(E[] list) { for (int i = 0; i < list.length; i++){ System.out.print(list[i] + " "); } System.out.println(); } } What is the output of running class GenericMethodDemo of the following code? public class GenericMethodDemo { public static void main(String[] args ) { Integer[] integers = {1, 2, 3, 4, 5}; String[] strings = {"London", "Paris", "Dhaka", "Austin", "Sydney"}; GenericMethodDemo.print(integers); GenericMethodDemo.print(strings); } public static void print(E[] list) { for (int i = 0; i < list.length; i++){ System.out.print(list[i] + " "); } System.out.println(); }
  • 2. } Solution output 1 : London Paris Dhaka Austin Sydney The above is the output of hte above program