JAVA
QUESTION 1
The value returned by a value-returning method can be saved for further calculation in the program.
True
False
QUESTION 2
To use a predefined method you must know the code in the body of the method.
True
False
QUESTION 3
A formal parameter is a variable declared in the method heading (ie. it's signature).
True
False
QUESTION 4
A local identifier is an identifier that is declared within a method or block and that is visible only within that method or block.
True
False
QUESTION 5
No two methods in the same class can have the same name.
True
False
QUESTION 6
Void methods have no return type.
True
False
QUESTION 7
The return statement must be the last line of the method.
True
False
QUESTION 8
When a program executes, the first statement to execute is always the first statement in the main method.
True
False
QUESTION 9
Given the method heading
public static String exampleMethod(int n, char ch)
what is the return type of the value returned?
|
int |
||
|
char |
||
|
String |
||
|
Nothing will be returned |
QUESTION 10
The method toString() is used to convert an object to a String object.
True
False
1) True 2) False 3) True 4) True 5) False 6) True 7) False 8) False 9) String 10) True
JAVA QUESTION 1 The value returned by a value-returning method can be saved for further calculation...
I need java code for the following problem.
Lab 7: Methods 1. Write a Java program called Numbers that calls the following methods and displays the returned value: Write a method called cubelt that accepts one integer parameter and returns the value raised to the third power as an integer. o Write a method called randominRange that accepts two integer parameters representing a range. The method returns a random integer in the specified range inclusive. 2. o Write a method...
ANY ANSWER IS MUCH APPRECIATED. THANK YOU!! QUESTION 1 ________ are useful for returning more than one value from a method. Default arguments Parameter lists Reference parameters Named arguments 1 points QUESTION 2 When you call a ________ method, it executes its code and returns without passing any value back to the program statement that called it. void private terminal value-returning 1 points QUESTION 3 You can pass string literals as arguments to methods containing string parameters. True False...
Why is my java method returning "-1" even if the string is in the array? The method is: public static int findWord(String wordToFind { boolean found=false; int i=0; while (i<words.length&& !found) if (words[i]==wordToFind) found=true; else i++; if (found) return i; else return -1; ...
Write a program that write a value-returning function, isVowel, that returns the value true if a given character is a vowel and otherwise returns false. You must insert the following comments at the beginning of your program and write our commands in the middle: Write a C++ Program: /* // Name: Your Name // ID: Your ID */ using namespace std; #include <iostream> using namespace std; bool isVowel(char ch); int main() { char ch; … … ...
true or false in JAVA 1) A literal value is a value that is typed directly into the code, such as 10, 14.6, or "Bob". 2) Local variables can only be accessed from within the block in which they are defined. 3) All variables must be declared before they can be used. 4) If a method returns nothing, its return type should be null. 5) A method with an int parameter can be invoked with a String argument. 6) A...
. Design a class named MyInteger. The class contains: An int data field named value that stores the int value represented by this object. A constructor that creates a MyInteger object for the specified int value. A getter method that returns the int value. The methods isEven(), is Odd(), and isPrime() that return true if the value in this object is even, odd, or prime, respectively. The static methods isEven(int), isOdd(int), and isPrime(int) that return true if the specified value...
IN JAVA 38. What is the return type of the String class compareTo( ) method? A) boolean B) int C) String D)coid 39. What is the return type of the constructor method of a class? A) void B) Object C) no return type is allowed D) int 40. A class can have many different constructor methods as long as the names are different. A)true B) false
Use Java to answer the question (Occurrences of a specified character) Write a method that finds the number of occurrences of a special character in a string using the following header: public static int count (String str, char a) For example, count("Welcome", 'e') returns 2. Write a test program that prompts the user to enter a string followed by a character then displays the number of occurrences of the character in the string. In addition to the requirements described in...
QUESTION 1 Each class must be declared in its own .java file True or False? QUESTION 2 The keyword this must always be explicitly used when referring to an object's instance variables and methods from within one of its non-static methods. True or False? QUESTION 3 When used in a class' main method the this keyword references the object representing the class itself. True or False? QUESTION 4 Accessor methods that test whether a condition is true or false are...
Consider the following methods’ headers: public static int one(int a, char b, double c, String d) public static double two(double x, double y) public static char three(int r, int s, char t, double u) Answer the following questions: Q1) What is the signature of method one? Answer: Q2) What is the return type of method two? Answer: Q3) What the formal parameters of method three? Answer: Q4) How many actual parameters are needed to call the method three? Answer: Q5)...