What does the following code print out? class Main { public static void main (String[] args) { int [] myArray = {3, 41, 7, 12, 9, 1, 15, 11, 17}; int result = mystery (myArray) ; System.out.println (result): } private static int mystery (int [] arr) { int number = 0; for (int i = 0; i < arr.length; i++) { if (arr[i] > 8) { number += arr[i]; } return number; O41 O 105 O3,7, 1, 15, 11, 17 83
Q: 2. Simple Calculator V 2.0 Modify your Calculator program from the Selections Lesson, so that it…
A: The given problems are related to java programming where various actions are to be performed in the…
Q: public class P1 { public static void main (String args[]) { int[] numbers = {2,4,10,11,14,28}; int…
A: Here in this question we have given a Java code segment and we have asked to find the output of this…
Q: - CPS150 GaussLab2.java Open with - import java.util.Scanner; * CPS150 GaussLab2.java ** / ★ CPS 150…
A:
Q: public class Test { public static void main(String[] args) { Number x = new Integer (3);…
A: //we are getting the error because X is an Number and new Integer is an integer so we are not able…
Q: public class FirstEx_2ExplainCode static int counterObj= 0; public double salary = 0; public static…
A: public class FirstEx_2ExplainCodes { static int counterObj = 0; public double salary = O;…
Q: 1. Recursive Append On RecursiveAppend.java Write a recursive method appendNTimes that receives two…
A: public static String appendNTimes(String original, int n) { if(n == 0) return original; else…
Q: Plz rearrange the code so that it works Step 1 We will solve the given problem in Java language.…
A: Rearrange the code so that it works
Q: The String class is provided in the Java library.Provide your own implementation for the following…
A: Below is the required Java code to implement the given class and methods: - Explanation: - Defining…
Q: 2. Write a recursive method called Rec for the recursive formula below. f (0) f (x) = { f (1) 1 %3D…
A: ALGORITHM:- 1. Take input for n from user. 2. Call the function. 3. Store the result. 4. Print the…
Q: Complete the isPalindrome method to recursively determine whether the parameter str is a palindrome.…
A: Question Complete the isPalindrome: import java.util.*; public class PalindromeDetector{…
Q: how would you change the test method of the palindrome class so that it considerer all character,…
A: A Java program for the given criteria is as follows, File name: “Palindrome.java” //Import necessary…
Q: public class output{ public static int find (int a1, int a2) { if(a1==0) return(a1+1); else if(a1>0…
A: There is a class output in which two method are there find and main. Find method is recursively…
Q: Q27 for java programing: public static void main(String[] args) { Dog[] dogs = { new…
A: Find the required answer with explanation given as below :
Q: public class Con{ public static void main(String[] args) { int[] ar=(2,5,7,9}; int i-2; final int…
A: Ouput of the java code public class Con{public static void main(String[] args){int[]…
Q: 1 public class Con{ public static void main(String[] args) 3- { int[] ar-{2,5,7,9}; 5 int i-2; final…
A: Error: cannot assign a value to final variable j
Q: Help with java Please import java.util.*; public class Recursion{ public static void…
A: Java program which take user input and add the user input according to its lenght
Q: public class P3 { public static void main(String[] args) { int[] intArray = new int[10]; for (int i…
A: It basically put value of i into array arrar[i] basically it adds number from 0 to 9…
Q: Whats the output to this? public static void main(String[] args) { twinInt s =…
A: According to the question below the Solution:
Q: What is the error(s) in the following Java program? class Person{ public class Test{ int Age; public…
A: Following are the errors: 1. When the constructor is defined then we have passed a parameter with…
Q: Write a recursive method that displays a string reversely on the console using the following header:…
A: Reverse a String using recursion. The required Java program is implemented below. Recursion Logic :…
Q: 1. Recursive Append On RecursiveAppend.java Write a recursive method appendNTimes that receives two…
A: public static String appendNTimes(String original, int n) { if(n == 0) return original; else…
Q: Identify the user-defined method based on the program given below. public class Mark int mark1,…
A: The answer is as follows:-
Q: public class MathF{ public static void main(String[] args) { char[] grade=new char[4]; grade[1]='B';…
A: Provided the output of the above code in the next step with a screenshot.
Q: What does the following code print out? class Main { public static void main (String[] args) { int…
A: c) 17
Q: public static void methodl (int i, int num) { for (int j System.out.print num = 2; 1; j <= i; j++) {…
A: The given code is written in Java.
Q: What is the output of the following code? public class Test { public static void main(String[] args)…
A: The answer is D) 12 13 14 15
Q: Write a static recursive method called mrecursiv that displays all of the permutations of the…
A: Find the required code in C++ as language not mentioned given as below and output :
Q: You are given the below Java code: 1 public class Student( public String name; public double gpa; 3.…
A: Find the answer with reason given as below :
Q: The String class is provided in the Java library.Provide your own implementation for the following…
A: Program structure Import class Arrays from the util package in the program. Create a Main class…
Q: 3. What would be the output of the following code: import java.util.*; public class Test { public…
A: The given problem has a code in Java language andthe requirement is to understand the code and then…
Q: Please, show the recursive flow in details public class Trace{ public static void main (String 0…
A: RECURSIVE FLOW DIAGRAM:
Q: For any element in keysList with a value greater than 50, print the corresponding value in…
A: In java it is possible to declare the key and it’s corresponding element. In this program keys and…
Q: Write a Java program for the following Class Diagram. Document -authors : Stringl date : Date…
A: package database; public class Book{ /* at the very beginning we require to create instance…
Q: public static void main(String[] args) { int[] a = new int[] {1,2}; swap (a); for (int i =…
A: public class Main{ public static void swap(int [] array){ int temp=array[0];…
Q: class box { int width; int height; int length; int volume;…
A: The given code:- class box { int width; int height; int length; int volume; void…
Q: • Write a recursive method that displays an int value reversely on the console using the following…
A: Java is a programming language. It contains extensive libraries (package). It can be used to create…
Q: public class output[ public static void main(String[] args) { int [][] D= new int [3][3]; int [] c =…
A: - We need to talk about the program and produce it's output.
Q: What is the printout of the following code? public class Test { public static void main(string[]…
A: public class Test { public static void main(String[] args) { int[][] matrix = {{0, 1, 2, 3}, {4, 5,…
Q: dd the method below to the parking office.java class. Method getParkingCharges(Customer) : Money…
A: The given function getParkingCharges() is implemented which takes in a customer details and returns…
Q: 1 class Metov{ 2- void sum(int i,int j){ 3 System.out.printin(i); } 4 void sum(String c,String d){ 5…
A: I have given an answer in step 2.
Q: 1 public class MathF( public static void main(String[] args) 3 { char[] grade-new char[4]; 4…
A: Answer:
Q: What is the output of the following code? import java.util.*; class Main { public static void…
A: import java.util.*;public class Main{ public static void main(String args[]) {…
Q: public class Main { static int findPosSum(int A[], int N) { if (N 0) return…
A: As you have posted multiple questions, we will solve the first three question for you. 1. If there…
Q: public class main { public static void main(String [] args) { Dog dog1=new…
A: Program: public class main { public static void main(String [] args) { Dog dog1=new…
Q: w int[a.length]; for(int i = 0; i < a.length; i++) { for(int j = 0; j < b
A: explained as,
Q: public class output{ public static void main(String [] args){ int [][] D int [] C = {0,0,1}; new int…
A: Output - 11 Stack Trace of outpur
Q: class Progarm1 { public static void main(String[] args) { int[] a = {1, 2}; q3(a);…
A: Given: Comparision between two programs
Q: public class P2 { public static void main(String[] args) { int[][] a2 = new int[3][3]; for (int i=0;…
A: According to the information given:- We have to compile this code and find out its output.
Q: Java - How many recursive calls will be made if the following method is called with 6? void…
A: Java Java is a programming language that is employed by developers to develop apps for mobile…
Q: The String class is provided in the Java library. Provide your own Java implementation for the…
A: Explanation: charAt() The charAt () function of the Java-String class produces the character…
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
- Analyse the following code: public class Test { public static void main(String[] args) { int[] oldList = {1, 2, 3, 4, 5}; reverse(oldList); for (int i = 0; i < oldList.length; i++) System.out.print(oldList[i] + " "); } public static void reverse(int[] list) { int[] newList = new int[list.length]; for (int i = 0; i < list.length; i++) newList[i] = list[list.length - 1 - i]; list = newList; } } A. The program displays 1 2 3 4 5 and then raises an ArrayIndexOutOfBoundsException. B. The program displays 5 4 3 2 1. C. The program displays 1 2 3 4 5. D. The program displays 5 4 3 2 1 and then raises an ArrayIndexOutOfBoundsException.Please help debug this: Debugging Exercise 4-3, Farrell, Joyce, Java Programming, 9th edition, Cengage Learning public class DebugBox { private int width; private int length; private int height; private FixDebugBox() { length = 1; width = 1; height = 1; } public DebugBox(int width, int length, int height) { width = width; length = length; height = height; } public void showData() { System.out.println("Width: " + width + " Length: " + length + " Height: " + height); } public double getVolume() { double vol = length - width - height; return vol; } }a Java static method that will take an array of strings as its only parameter. The method will return the first string alphabetically (lowest) in the array.
- Complete the sumOfDiagonals method in SumOfDiagonals.java to do the following public class SumOfDiagonals { public static void main(String[] args) { String[][] s1 = {{"2", "3", "4"}, {"5", "6", "7"}, {"8", "9", "10"}}; String[][] s2 = {{"1", "2", "3"}, {"5", "6", "7"}, {"9", "10", "11"}, {"13", "14", "15"}}; String[][] s3 = {{"1", "2", "3", "4"}, {"5", "6", "7", "8"}, {"9", "10", "11", "12"}, {"13", "14", "15", "16"}}; try { sumOfDiagonals(s1); sumOfDiagonals(s2); sumOfDiagonals(s3); } catch(NumberFormatException ex) { System.out.println("Not a valid integer"); } catch(IllegalArgumentException ex) { System.out.println("Array not a square"); } } public static void…public class LabProgram { public static void main(String args[]) { Course course = new Course(); String first; // first name String last; // last name double gpa; // grade point average first = "Henry"; last = "Cabot"; gpa = 3.5; course.addStudent(new Student(first, last, gpa)); // Add 1st student first = "Brenda"; last = "Stern"; gpa = 2.0; course.addStudent(new Student(first, last, gpa)); // Add 2nd student first = "Jane"; last = "Flynn"; gpa = 3.9; course.addStudent(new Student(first, last, gpa)); // Add 3rd student first = "Lynda"; last = "Robison"; gpa = 3.2; course.addStudent(new Student(first, last, gpa)); // Add 4th student course.printRoster(); } } // Class representing a student public class Student { private String first; // first name private String last; // last name private double gpa; // grade point average…THIS NEEDS TO BE DONE IN C#! NOT JAVA! NOT C++, NOT PYTHON! PLEASE WRITE THIS IN C#! Take the following class: class Pokemon { string Name; string Type; int Health; } Override the ToString method so that it it outputs the Pokemon's heath. Example: Let's say we have a Pikachu named Sparky and it had 200 health. When we called ToString, we would get the following string: Rex: Pikachu (200)
- Write a recursive method that displaysa string reversely on the console using the following header: public static void reverseDisplay(String value) For example, reverseDisplay("abcd") displays dcba. Write a test programthat prompts the user to enter a string and displays its reversal.when an individual array element of an array of type int is passed to a method, it is passed by reference. True False note : in a javaThe intName method in the "Problem Solving: Stepwise Refinement" section accepted arguments < 1,000. Using a recursive call, extend its range to 999,999. For example an input of 12,345 should return " twelve thousand three hundred forty five". Note that some number names may have extra spaces at the beginning or end. import java.util.Scanner; public class IntegerName { /** Turns a number into its English name. @param number a positive integer < 999,999 @return the name of the number (e.g. "two hundred seventy four") */ public static String intName(int number) { int part = number; // The part that still needs to be converted String name = ""; // The name of the number if (part >= 1000) { // Recursively call intName } if (part >= 100) { name = digitName(part / 100) + " hundred"; part = part % 100; } if (part >= 20) { name = name + " " + tensName(part); part = part % 10; } else if (part >= 10) { name = name + " " + teenName(part); part = 0; } if (part > 0) { name =…
- The language used here is in Java. Please answer the question in the screenshot. Please use the code below as a base. Please only answer question 2. import java.util.*; class SortingPack { // just in case you need tis method for testing public static void main(String[] args) { // something } // implementation of insertion sort // parameters: int array unsortedArr // return: sorted int array public static int[] insertionSort(int[] unsortedArr) { // to be removed return unsortedArr; } // implementation of quick sort // parameters: int array unsortedArr // return: sorted int array public static int[] quickSort(int[] unsortedArr) { // to be removed return unsortedArr; } // implementation of merge sort // parameters: int array unsortedArr // return: sorted int array public static int[] mergeSort(int[] unsortedArr) { // to be removed return unsortedArr; } // you are welcome to add any supporting methods } import java.util.*; public class SortingTest{ public static void main(String[] args) {…Write a recursive Java method that takes a String as a parameter and returns true if the String is a palindrome. You may assume that the string only contains lower case characters (i.e. no numbers, spaces, punctuation, etc).Q27 for java programing: public static void main(String[] args) { Dog[] dogs = { new Dog(), new Dog()}; for(int i = 0 ; i < dogs.length; i++) dogs[i].wo(); Cat[] cats = { new Cat(),new Cat(),new Cat()}; for(int i = 0 ; i < cats.length; i++) cats[i].me(); System.out.print(Dog.getCount()+" woofs and"); System.out.println(Cat.getCount()+" mews"); System.out.println("=====>>>"+decision()); } class Counter { private static int count; public static void inc() { count++;} public static int getCount() {return count;} } class Dog extends Counter{ public Dog(){} public void wo(){inc();} } class Cat extends Counter{ public Cat(){} public void me( ){inc();} } The Correct answer: public static void main(String[] args) { Dog[] dogs = { new Dog(), new Dog()}; for(int i = 0 ; i < dogs.length; i++) dogs[i].wo(); Cat[] cats = { new…