Check the following 2 codes carefully and what will happen, if the following codes are executed....
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Check the following 2 codes carefully and what will happen, if the following codes are executed. public class Family { String[] members; //-- // Constructor: Sets up this family by storing the (possibly // multiple) names and int that are passed in as parameters. //---- public Family (String...names, int no) { members = names; } //-- // Returns a string representation of this family. //---- public String toString( ) { String result = ""; for (String name : members) result + name + "\n"; return result; } } public class VariableParameters { //--- // Creates two Family objects using a constructor that accepts // a variable number of String objects and int as parameters. public static void main(String[] args) { Family lewis = new Family ("John", "Sharon", "Justin", "Kayla", "Nathan", "Samantha", 6); //6 values Family camden = new Family (9, "Stephen", "Annie", "Matt", "Mary", "Simon", "Lucy", "Ruthie", "Sam", "David", 9); // 9 values System.out.println(lewis); System.out.println(); System.out.println(camden); } } Α Check the following 2 codes carefully and what will happen, if the following codes are executed. public class Family { String[] members; //-- // Constructor: Sets up this family by storing the (possibly // multiple) names and int that are passed in as parameters. //---- public Family (String...names, int no) { members = names; } //-- // Returns a string representation of this family. //---- public String toString( ) { String result = ""; for (String name : members) result + name + "\n"; return result; } } public class VariableParameters { //--- // Creates two Family objects using a constructor that accepts // a variable number of String objects and int as parameters. public static void main(String[] args) { Family lewis = new Family ("John", "Sharon", "Justin", "Kayla", "Nathan", "Samantha", 6); //6 values Family camden = new Family (9, "Stephen", "Annie", "Matt", "Mary", "Simon", "Lucy", "Ruthie", "Sam", "David", 9); // 9 values System.out.println(lewis); System.out.println(); System.out.println(camden); } } Α
Expert Answer:
Answer rating: 100% (QA)
In the provided code the Family class constructor takes an int parameter followed by a varargs param... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Predictive text entry systems are familiar on touch screens and mobile phones. This question asks you to consider how the same principles might be used in a programming editor for creating Java code....
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
Can you give us a few Google AdWords Ad Extensions names that you know?
-
The World Bank projects that the world's population will increase from 7 billion today to 8 billion in 2025. World output today is roughly $80 trillion. 1. What is global per capita income today? 2....
-
The normal to the curve at the point (9, 4) meets the x-axis at P and the y-axis at Q. Find the length of PQ, correct to 3 significant figures. y = 12
-
Increasingly, we are seeing email used in cases involving defendants located in foreign countries. Plaintiffs filed suit against four Defendants: Qingdao Sunflare New Energy Co., Skone Lighting Co.,...
-
Data pertaining to the current position of Brin Company are as follows: Cash .................$520,000 Temporary investments ..........380,000 Accounts and notes receivable (net) .....700,000...
-
In relational model, how to distinguish different keys (primary key,superkey, foreign key and so on)?
-
Hastings College pooled the individual investments of three of its funds on December 31, 2024. The recorded value and the fair market value of the investments on December 31, 2024, are presented...
-
A company needs to decide whether or not to grant credit to a new customer for a one-time sale. The price per unit is $60,000 and variable cost per unit is $40,000. If the customer is granted credit...
-
A box with a rectangular base and no lid is to be made out of two types of wood. The wood for the sides costs $11/m2 and the wood for the base costs $7 /m2. If the total volume of the box must be 6...
-
1 SUMMARY For this assignment, you will be writing some code to play the game blackjack. You will write one class, and also a blackjack playing bot that tries to win as many chips as possible. Your...
-
A manufacturing plant you consult at makes two products (ADA and ETH) and is considering switching to ABC. The following information is available: ADA ETH Direct materials per unit $ 35.25 $ 25.55...
-
Writing a class named ChessVar for playing an abstract board game that is a variant of chess. The following explanation of the rules assumes some familiarity with the rules of chess - specifically...
-
What are the three characteristics of tangible personal property classified as inventory? What are some commonly used names for inventory found on a merchandisers or manufacturers balance sheet?
-
A right circular cylindrical tank has a radius of 5 meters and height of 10 meters. If it is half-filled with water, find the work needed to pump the content to the top of the tank.
-
You have just begun your summer internship at Omni Instruments. The company supplies sterilized surgical instruments for physicians. To expand sales, Omni is considering paying a commission to its...
-
Lisa Sizemore, a taxpayer in the 10-15 percent tax bracket, purchased stock as an investment on July 11, 2011. She sold the stock on July 9, 2012, 2 days before qualifying for the long-term holding...
-
Diane is a single taxpayer who qualifies for the earned income credit. Diane has two qualifying children who are 3 and 5 years old. During 2012, Diane's wages are $17,100 and she receives dividend...
-
During the 2012 tax year, Irma incurred the following expenses: Union dues..............................................................$275 Tax return preparation...
-
Identify the sources and discuss the consequences of bank runs, bank panics, and financial crises.
-
Explain why and how the government intervenes in the financial system, and the problems the government safety net creates.
-
Deflation is the rate of decline in the aggregate price level. Why might unexpected deflation be of particular concern to someone managing a bank?
Study smarter with the SolutionInn App