1)What is the return type of a method that does not return any value? a) int b) float c) void d) double
Q: The return statement of a void method may have one of two forms (assuming x is an int). to return x…
A: Introduction: Void methods don't produce any output because they are declared to be empty. A return…
Q: What the following code does? int * foo = new int [5]; if (!foo) { ...}
A: To find what the given code does - int *foo = new int[5]; if(!foo) {........}
Q: A void method may contain a return statement in which form (assume x is int)? o return x; o return…
A: option(C) is the correct option
Q: n physics, an object that is in motion is said to have kinetic energy. The following formula can be…
A: I give the code in Java along with output and code screenshot
Q: True or False: When passing multiple arguments to a method, the order in which the arguments are…
A: Given: True or False: When passing multiple arguments to a method, the order in which the arguments…
Q: What is the output of the following code? int x = 0; void main()
A: Here have to determine correct option for given c code and gives correct output option.
Q: Define a method in JAVA that should take 4 numbers as the parameters and returns the average of all…
A: Here I have created the function named average(). In this function, I have added all 4 number passes…
Q: A __________ belongs to the method in which it is declared, and only statements inside that method…
A: Variable belonging to the declared method The local variables are the variables that are declared…
Q: QUESTION 14 Multiple Choice: Which of the statements is FALSE regarding the code below ? public…
A: please upvote for my efforts thanks! answer: 14) the scope of y is inside the if statement hence…
Q: 9. Follow the comments to insert the missing parts of the code below: // Create a checkAge () method…
A: static void ..........(....... ..........){ ...........(..... ......... ........ ){…
Q: Declare a method with three arguments all of the type int. The method should return the greatest of…
A: The program is written in java. Please find the program in below step.
Q: Void methods can accept arguments. O True O False
A: We are going to learn if void methods can accept arguments.
Q: Toll roads have different fees based on the time of day and on weekends. Write a method calcToll()…
A: First we will convert both the time intervals given (i.e. Weekdays and Weekends) into minutes only.…
Q: (c) Write the statement to call the method max3 () in question 4(g).
A: Dear Student, To call a function we first declare a variable where we want the value to be stored…
Q: g) Write statement to call method getArea using object crl.
A: Given :
Q: Complete the class Problem 1, the program does the following: Prompt the user to enter an integer n.
A: Please find the answer below :
Q: (Number of days in a year) Write a method that returns the number of days in a year using the…
A: public class Solution { public static boolean isLeayYear(int y) { // if leap year…
Q: 1.Using pseudocode, a method that will add two numbers, and return the sum to the calling function.…
A: The, code has given below:
Q: Embed your method in a complete program that requests for three variables all of the types int and…
A: The answer for the above question is given in the below steps for your reference.
Q: What is the return type of a method that does not return any value? a)int b)void c)float…
A: correct option: B
Q: Code in C# (OOP Concept) Do a program that does the following: Ask for a number from the user in…
A: Step 1:- The first program in the C# programming language and the second program in the C++…
Q: 6.25 LAB: Track laps to miles One lap around a standard high-school running track is exactly 0.25…
A: According to the information given:- We have to follow the instruction in order to get the desired…
Q: 5. Assume each of the following has the same name, which of the following methods are overloaded…
A: Step 1:- Method Overloading is also known as Function overloading which means the method has…
Q: public void Unknown() if
A: Given :
Q: Construct 2 methods: void Input() and void maxNum(). The input method should allow user to input 3…
A: Java program to implement void Input() and void maxNum(): import java.util.Scanner;public class…
Q: Write an application that calculates the product of a series of integers that are passed to method…
A: A method with variable length arguments can have zero or multiple arguments.
Q: T/F 5) The following two methods will both compute the same thing when invoked with the same value…
A: Answer is : True Please refer the below example in Step2 window and its output. Here +1 is done in…
Q: T/F 5) If you call the following two methods with the same value of x, they would both return the…
A: Suppose x = 2 If method1(2) is called then it will return 0+1+1=2. On the other hand, if method2(2)…
Q: A void method may contain a return statement in which form (assume x is int)? return x return 10;…
A: There a re various return type of a method. Void is one of them, if a method is declared void it can…
Q: T/F 2) The following method lacks a base case. public int noBaseCase(int x) { if(x > 0) return…
A: Given that, The following method lacks a base case.public int noBaseCase(int x){if(x > 0)return…
Q: construct 2 methods: Void input() and void maxNum(). The input method should allow user to input 3…
A: if statement evaluates whether an expression is true or false.
Q: Use python, import sys, sys.argv to create a program called classname.py. The program should define…
A: please see the next step for solution
Q: 29. Fill in the Blanks: A __________ is a collection of statements that are grouped together to…
A: Which of the following options is a collection of statements that are grouped together to perform an…
Q: Can arrays be used as a return valu
A: A return value is the value that is obtained as output whenever a function or a method gets executed…
Q: True or FalseA value-returning method must contain a return statement.
A: Value-returning method: The value-returning method performs the task and does not terminate. The…
Q: f the method body has return 5.7 , what should be in the header: public static ___ methodName (int…
A: EXPLANATION: The return-type is the data type that the function or method returns to the instruction…
Q: You can declare a void method as follow; public void int calculateSalary() { int num1=89; int…
A: WE have to find weather the syntax is correct or not.
Q: c. The Ghana Statistical Services (GSS) is interested in your statement in “b” above but it is of…
A: The Complete answer is given below:
Q: Find the error(s) in the following code snippet and explain how to correct it (them): 1 class…
A: The function prototype of getIncrementedData is : int getIncrementedData() const {} which makes is…
Q: T/F 2) There is no base case in the following method. public int noBaseCase(int x) { if(x > 0)…
A: Given that, There is no base case in the following method. public int noBaseCase(int x){if(x >…
Q: Is it possible to write a method that returns any type of data?
A: Intro the above question is about Is it possible to write a method that returns any type of data…
Q: Write a method named isEven that accepts an int argument. The method should return true if the…
A: As no programming language is mentioned, it is solved using Java
Q: Q1 \ write program in C# language to find the average of student marks in three subjects…
A: First, we will input the marks in 3 subjects. Then we will call the function avg_no. This function…
Q: ind the error(s) in each of the following and explain how to correct it (them):a) Assume the…
A: a) Assume the following prototype is declared in class Time:void ~Time( int );
Q: 7. Complete the code: public class Test public static void main(String [] args) int i = 4; int j =…
A: According to the Question below the Solution:
Q: a. int i = (double) 3; 3.4; b. int i c. int i = ((int) 4..3* 10)/10.0; d. int i (int) 2) Which one…
A: Type casting means changing a variable from one data type to another data type. In some cases, the…
Q: *6.7 (Financial application: compute the future investment value) Write a method that computes…
A: Solution :: 6.7 ) The following is the modfied program. you did not call the function…
Q: True or False: During method calls, the value of a local variable is preserved.
A: Given To know about value of a local variable is preserved or not when a method is called.
Sir please Solve both mcq's
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
- public static String pancakeScramble(String text) This nifty little problem is taken from the excellent Wolfram Challenges problem site where you can also see examples of what the result should be for various arguments. Given a text string, construct a new string by reversing its first two characters, then reversing the first three characters of that, and so on, until the last round where you reverse your entire current string.This problem is an exercise in Java string manipulation. For some mysterious reason, the Java String type does not come with a reverse method. The canonical way to reverse a Java string str is to first convert it to mutable StringBuilder, reverse its contents, and convert the result back to an immutable string, that is,str = new StringBuilder(str).reverse().toString(); Here's the tester it must pass: @Test public void testPancakeScramble() throws IOException {// Explicit test casesassertEquals("", P2J3.pancakeScramble(""));assertEquals("alu",…public static String pancakeScramble(String text) This nifty little problem is taken from the excellent Wolfram Challenges problem site where you can also see examples of what the result should be for various arguments. Given a text string, construct a new string by reversing its first two characters, then reversing the first three characters of that, and so on, until the last round where you reverse your entire current stringPublic class Utilities { getDigits Method: public static java.lang.String getDigits(java.lang.String str) Returns a string with the digits (if any) present in the str parameter. You can assume str will never be null. You can use Character.isDigit() to determine whether a character is a digit. You may not use an auxiliary method in order to implement this method. Your implementation must be recursive and you may not use any loop construct. From the String class, the only methods you can use are length(), isEmpty(), charAt() and substring. Do not use ++ or -- in any recursive call argument. It may lead to an infinite recursion. For example, use index + 1, instead of index++. Parameters: str - Returns: String with digits or empty string
- Java Without using any java functions, data structures, libraries, string builder or anything complicated. Please make a program that takes out the tokens in a string. For example "90+5" -> 90 + 5 Make It so it is null if string is empty " " --> null Make it so it is null if expression is invalid "++7 - 0" --> null and "..7 + 0" --> null Use this for loop to iterate through the list for (int i = 0; i < exprn.length(); i++) {private static String extractVowelHelper(String str, int start, String vowels) { // base case // recursive step }Fix all the errors in the code // Program displays some facts about a string public classDebugSeven3 { public static void main(String[] args) { String quote = "Honesty is the first chapter in the book of wisdom. - Thomas Jefferson"; System.out.println("index.of('f') is: " + quoteindexOf('f')); System.out.println("index.of('x') is: " + quoteindexOf('x')); System.out.println("char.At(5) is: " + quote.charAt(50)); System.out.println("endsWith(\"daughter\") is: " + quote.endsWith("daughter")); System.out.println("endsWith(\"son\") is: " + quote.endsWith("son")); System.out.println("replace('e', '*') is: ", quote.replace('e', '*')); } }
- Use for loop in Java language Write the method stringSplosion().* * The method takes one parameter, a non-empty String str (such as "Code") and* returns a String in the form "CCoCodCode". Notice that this includes the* first character of the original String, followed by the first two characters,* and so on until the whole String is used.* * Examples: stringSplosion("Code") returns "CCoCodCode" stringSplosion("abc")* returns "aababc" stringSplosion("x") returns "x"* * @param str the input String to process.* @return a new String as described above.java: Run length coding is a method to represent a string in a more compact manner. Each character that occurs more than 2 times in a row is represented by the character and a number following it. Two examples are: "abba" → "abba""abcccbbbba" → "abc3b4a"Write a function that calculates how many characters the encoded string is shorter than the original.Make the code output sentence starts with a capitalization, and ends with a period. public class Word implements IWord{ private String word; public Word(String word){ this.word = word; } @Override public String getWord(){ return word; }} public class CompoundWord implements IWord { private IWord word1; private IWord word2; public CompoundWord(IWord w1, IWord w2){ word1 = w1; word2 = w2; } @Override public String getWord(){ return word1.getWord() + word2.getWord(); } } import java.util.ArrayList;public class Sentence { private ArrayList<IWord> words; public Sentence(){ words = new ArrayList<IWord>(); } public Sentence add(IWord word){ words.add(word); return this; } public String getSentence(){ String result = ""; for(IWord word:words) result += word.getWord()+" "; return…
- JAVA Language: Transpose Rotate. Question: Modify Transpose.encode() so that it uses a rotation instead of a reversal. That is, a word like “hello” should be encoded as “ohell” with a rotation of one character. (Hint: use a loop to append the letters into a new string) import java.util.*; public class TestTranspose { public static void main(String[] args) { String plain = "this is the secret message"; // Here's the message Transpose transpose = new Transpose(); String secret = transpose.encrypt(plain); System.out.println("\n ********* Transpose Cipher Encryption *********"); System.out.println("PlainText: " + plain); // Display the results System.out.println("Encrypted: " + secret); System.out.println("Decrypted: " + transpose.decrypt(secret));// Decrypt } } abstract class Cipher { public String encrypt(String s) { StringBuffer result = new…Complete the isPalindrome method to recursively determine whether the parameter str is a palindrome. import java.util.*; public class PalindromeDetector{ public static boolean isPalindrome(String str){ /*********************************** WRITE THIS METHOD **********************************/ return false; //temporary statement to allow compilation } public static void main(String[] args){ List<String> allWords = new ArrayList<String>(); Scanner input = new Scanner(System.in); System.out.println("Enter a string, 0 to quit"); String str = input.nextLine(); while (!str.equals("0")){ allWords.add(str); System.out.println("Enter a string, 0 to quit"); str = input.nextLine(); } List<String> palindromes = new ArrayList<String>(); for (String test : allWords) { if (isPalindrome(test.toUpperCase())){ palindromes.add(test); } } Collections.sort(palindromes); if (!palindromes.isEmpty()){ System.out.println("Your palindromes are:");…Subject - Data Structure Please help me to debug my error. Thank you in advance! import java.util.Scanner;public class LinearSearchDemo { private static int linearSearch(int[] numbers, int key) { for (int i = 0; i < numbers.length; i++) { if (numbers[i] == key) { return i; } } return -1; // not found } // Main program to test the linearSearch() method public static void main(String[] args) { int[] numbers = { 2, 4, 7, 10, 11, 32, 45, 87 }; System.out.print("NUMBERS: "); for (int i = 0; i < numbers.length; i++) { System.out.print(numbers[i] + " "); } System.out.println(); Scanner scnr = new Scanner(System.in); System.out.print("Enter an integer value: "); int key = scnr.nextInt(); int keyIndex = linearSearch(numbers, key); if (keyIndex == -1) { System.out.println(key + " was not found."); } else { System.out.printf("Found %d at index…