Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 7.13, Problem 7.13.1CP
This book declares the main method as
public static void main(String[] args)
Can it be replaced by one of the following lines?
- a. public static void main (String args[])
- b. public static void main (String[] x)
- c. public static void main (String x[])
- d. static void main (String x [] )
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
What will happen when you compile and run the following code? #1. public class Test{
public static void main(String[] args){
int a = 10, b = 0;
while( a + 2 < 10 || b - 2 > 0){
System.out.println(a);
}
}
}
#2. public class Test{
public static void main(String[] args){
int a = 0, b = 10;
while(b - 40 > 0){
b -= 2;
while(a + 12 < 10){
a += 2;
if(a == b)
continue;
System.out.print(a + " " + b + ", ");
}
}
}
}
show the output and solution, its java language
I know you guys can answer 3 Multiple choice at atime but please answer one extra so I do not have to ask one more question.
7.) Which of the following is correct? a. String[] list = new String{"red", "yellow", "green"}; b. String[] list = new String[]{"red", "yellow", "green"}; c. String[] list = {"red", "yellow", "green"}; d. String list = {"red", "yellow", "green"}; e. String list = new String{"red", "yellow", "green"}; 8.) What are the base cases in the following recursive method? public static void xMethod(int n) { if (n > 0) { System.out.print(n % 10); xMethod(n / 10); } } a. n > 0 b. n <= 0 c. no base cases d. n < 0
9.) Fill in the codeto complete the following method for computing factorial./** Return the factorial for a specified index */ public static long factorial(int n) { if (n == 0) // Base case return 1; else return _____________; // Recursive call } a. n * (n - 1) b. n c. n * factorial(n - 1) d. factorial(n - 1) * n 10.) All…
What is the output of the following program and show all your workings? public class Main{public static void main(String[] args) {System.out.printin(mystery(5));}static int mystery(int num){if(num <= 1)return 1;else{return mystery(num-1) + mystery(num—2) ;}
Chapter 7 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Ch. 7.2 - Prob. 7.2.1CPCh. 7.2 - Prob. 7.2.2CPCh. 7.2 - What is the output of the following code? int x =...Ch. 7.2 - Indicate true or false for the following...Ch. 7.2 - Which of the following statements are valid? a....Ch. 7.2 - Prob. 7.2.6CPCh. 7.2 - What is the array index type? What is the lowest...Ch. 7.2 - Write statements to do the following: a. Create an...Ch. 7.2 - What happens when your program attempts to access...Ch. 7.2 - Identify and fix the errors in the following code:...
Ch. 7.2 - What is the output of the following code? 1....Ch. 7.4 - Will the program pick four random cards if you...Ch. 7.5 - Use the arraycopy method to copy the following...Ch. 7.5 - Prob. 7.5.2CPCh. 7.7 - Suppose the following code is written to reverse...Ch. 7.8 - Prob. 7.8.1CPCh. 7.8 - Prob. 7.8.2CPCh. 7.9 - Prob. 7.9.1CPCh. 7.9 - Prob. 7.9.2CPCh. 7.10 - If high is a very large integer such as the...Ch. 7.10 - Prob. 7.10.2CPCh. 7.10 - Prob. 7.10.3CPCh. 7.11 - Prob. 7.11.1CPCh. 7.11 - How do you modify the selectionSort method in...Ch. 7.12 - What types of array can be sorted using the...Ch. 7.12 - To apply java.util.Arrays.binarySearch (array,...Ch. 7.12 - Show the output of the following code: int[] list1...Ch. 7.13 - This book declares the main method as public...Ch. 7.13 - Show the output of the following program when...Ch. 7 - (Assign grades) Write a program that reads student...Ch. 7 - (Reverse the numbers entered) Write a program that...Ch. 7 - (Count occurrence of numbers) Write a program that...Ch. 7 - (Analyze scores) Write a program that reads an...Ch. 7 - (Print distinct numbers) Write a program that...Ch. 7 - (Revise Listing 5.1 5, PrimeNumber.java) Listing...Ch. 7 - (Count single digits) Write a program that...Ch. 7 - (Average an array) Write two overloaded methods...Ch. 7 - (Find the smallest element) Write a method that...Ch. 7 - Prob. 7.10PECh. 7 - (Statistics: compute deviation) Programming...Ch. 7 - (Reverse an array) The reverse method in Section...Ch. 7 - Prob. 7.13PECh. 7 - Prob. 7.14PECh. 7 - 7 .15 (Eliminate duplicates) Write a method that...Ch. 7 - (Execution time) Write a program that randomly...Ch. 7 - Prob. 7.17PECh. 7 - (Bubble sort) Write a sort method that uses the...Ch. 7 - (Sorted?) Write the following method that returns...Ch. 7 - (Revise selection sort) In Listing 7 .8, you used...Ch. 7 - (Sum integers) Write a program that passes an...Ch. 7 - (Find the number of uppercase letters in a string)...Ch. 7 - (Game: locker puzzle) A school bas 100 lockers and...Ch. 7 - (Simulation: coupon collectors problem) Coupon...Ch. 7 - (Algebra: solve quadratic equations) Write a...Ch. 7 - (Strictly identical arrays) The arrays 1ist1 and...Ch. 7 - (Identical arrays) The arrays 1ist1 and 1ist2 are...Ch. 7 - (Math: combinations) Write a program that prompts...Ch. 7 - (Game: pick four cards) Write a program that picks...Ch. 7 - (Pattern recognition: consecutive four equal...Ch. 7 - (Merge two sorted Lists) Write the following...Ch. 7 - (Partition of a list) Write the following method...Ch. 7 - Prob. 7.33PECh. 7 - (Sort characters in a string) Write a method that...Ch. 7 - (Game: hangman) Write a hangman game that randomly...Ch. 7 - (Game: Eight Queens) The classic Eight Queens...Ch. 7 - Prob. 7.37PE
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Rewrite the temperature conversion program of Section 1.2 to use a function for conversion.
C Programming Language
3.12 (Date Create a class called Date that includes three pieces Of information as data
members—a month (type ...
C++ How to Program (10th Edition)
Suppose we have a system with the following properties: The memory is byte addressable. Memory accesses are t...
Computer Systems: A Programmer's Perspective (3rd Edition)
The only language a computer can directly understand is that computers.
Java How To Program (Early Objects)
Weekly Temperatures with Validation Programming Challenge 3 in Chapter 3 asked you to create an application tha...
Starting Out With Visual Basic (7th Edition)
On paper, write a program that will display your name on the screen. Place a comment with todays date at the to...
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- What is the output of the following Java program? class OverloadingCalculation3{ void sum(int a,long b){System.out.println("a method invoked");} void sum(long a,int b){System.out.println("b method invoked");} public static void main(String args[]){ OverloadingCalculation3 obj=new OverloadingCalculation3(); obj.sum(20,20);//now ambiguity } }arrow_forward2) Identify the errors in the following programs a) 3 errorspublic class Test {public static void main(String[] args) {System.out.println(method2(3.4));} public static int method1(int n) {if (n > 0) return 1;else if (n == 0) return 0;else if (n < 0) return -1;}} b) 2 errorspublic class Test {public static void main(String[] args) {nPrintln(5, "Welcome to Java!");}public static void nPrintln(String message, int n) {for (int i = 0; i < n; i++) {System.out.println(message);}return n;}}arrow_forwardManually trace the execution of the following Java code segment: (c) if the following method is declared: public static void drawLine(int num, char ch) { for (int i = 1; i <= num; i++) { System.out.print(ch); } } What does the statement drawLine(10, ‘$’) do?arrow_forward
- public class MysteryReturn2 {3 public static void main(String[] args)4 {5 int x = 1;6 int y = 2;7 int z = 3;89 z = mystery(x, z, y);10 System.out.println(x + " " + y + " " + z);11 }1213 public static int mystery(int c, a, int b);14 {15 c--;16 a = 2 * b + c;17 b = a - 1;18 System.out.println(b + " " + c);1920 return a;21 }22 } 1. The mystery method has three parameter variables, a, b, and c. What is the scope of these variables (that is, where can they be used by their name)?arrow_forwardProgram to compute interest = p * r * t, where p = $10K, rate = 6%, t = 10 years; these values are to be passed from main() Besides main() the program has two methods: one that computes the interest and on that rounds interest to two decimal places public class DisplayInterest public static void main(String[] args) call a method that will do the computation with values for the above variables; with the exception of year, they are double main() displays computed interest after rounding computation method() rounding method() Note:- Please type and execute this java program and also need an output for this java program.arrow_forwardConsider the method headings: void funcOne(int [ ] alpha, int size) int funcSum(int x, int y) void funcTwo(int [ ] alpha, int [ ] beta) and the declarations: int [ ] list = new int [50]; int [ ] Alist = new int [60]; int num; Write Java statements that do the following: a. Call the method funcOne with the actual parameters, the array list and 50, respectively. b. Print the value returned by the method funcSum with the actual parameters, the thirtieth and tenth components of list, respectively. c. Call the method funcTwo with the actual parameters, the array list and array Alist, respectively.arrow_forward
- What is the output of the main method shown below? public static void main(String []args){int result, w = 5, x = 4, y = 8, z = 2;result = x + y;System.out.println(result);result = z * 2;System.out.println(result);result = y / x;System.out.println(result);result = y - z;System.out.println(result);result = w % 2;System.out.println(result);}arrow_forwardThe following code prints the first print statement __________ times, the second print statement __________ times, for a total of ____________ total printed lines of text. /** * Main method. * * @param args command-line arguments (not used) */ public static void main(String[] args) { final int DAYS_IN_A_YEAR = 365; final int HOURS_IN_A_DAY = 24; for (int i = 0; i < DAYS_IN_A_YEAR; i++) { System.out.println("Today is day " + (i + 1) + " of " + DAYS_IN_A_YEAR); for (int j = 0; j < HOURS_IN_A_DAY; j++) { System.out.println("This is hour " + (j + 1) + " of " + HOURS_IN_A_DAY); } } } Select one: 365, 8760, 9125 364, 8736, 9100 366, 8784, 9150 nonearrow_forwardJava- Consider this method declaration: void quiz(int i) { if (i > 1) { quiz(i/2); quiz(i/2); } system.out.print(“*”); } How many asterisks are printed by the method call quiz(4) ?arrow_forward
- Identify the errors in the following programs. public class Test { public static void main(String[] args) { System.out.println(method2(3.4)); } public static int method1(int n) { if (n > 0) return 1; else if (n == 0) return 0; else if (n < 0) return -1; }}arrow_forwardWhat will be the output of the following Java code? And Explain.? class char_increment { public static void main(String args[]) { char c1 = 'D'; char c2 = 84; c2++; c1++; System.out.println(c1 + " " + c2); } }arrow_forwardFill with appropriate java keywords/syntaxes in the following method overloading program. package analyze; class { method (double X, double Y, double Z){ return X * Y * Z; } double method (double M, double ) { return M / N; } public class Analyze { public static void main(String[] args) { Find fi = Find(); System.out.println( Method 1 : "+fi.method(2, 4, 6)); System.out.println("Method 2 : "+fi.method(3, 6)); } }arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
CPP Function Parameters | Returning Values from Functions | C++ Video Tutorial; Author: LearningLad;https://www.youtube.com/watch?v=WqukJuBnLQU;License: Standard YouTube License, CC-BY