Java Questions When creating a for loop, which statement will correctly initialize more than one variable?…
The following solution is suggested to handle the subject “Java Questions When creating a for loop, which statement will correctly initialize more than one variable?…“. Let’s keep an eye on the content below!
Question “Java Questions When creating a for loop, which statement will correctly initialize more than one variable?…”
- Java Questions
- When creating a for loop, which statement will correctly
initialize more than one variable?
- When creating a for loop, which statement will correctly
a. | for a=1, b=2 | c. | for(a=1, b=2) |
b. | for(a=1; b=2) | d. | for(a = 1&& b = 2) |
- A method employee() is returning a double value. Which of the
following is the correct way of defining this method?
- A method employee() is returning a double value. Which of the
- public double employee()
c. public int employee() - public double employee(int
t)
d. public void employee()- The ____ statement is useful when you need to test a single
variable against a series of exact integer, character, or string
values.
- The ____ statement is useful when you need to test a single
a. | Switch | c. | else |
b. | If | d. | Break |
- You can leave out the ____ statements in a switch
structure.
a. | Break | c. | if |
b. | Switch | d. | Case |
- If your method is returning values ,what will replace the word
“void” in your method header.
- If your method is returning values ,what will replace the word
- return
c. datatype of return value -
void
d. null- Which is the correct for form for defining an object?
- classname objectname=new classname
- objectname classname=new objectname()
- d. ojectname,object name=new() ob
- classname objectname=new classname()
- Given below is a object creation statement for a class
customer.
- Given below is a object creation statement for a class
customer c=new customer(”ALI”,5)
Which will be the correct
way of defining a constructor?
- public void
customer()
c. public customer(int a, String t) - public customer(String t, int y) d. public void customer()
)
22. All Java application programs must
have this method to run.
- hello()
c.
start() - main(),
d. add()
- Examine the following code:
for(count = 7 ;count> =3; count
=count-1)
{
System.out.print(count+” “); }
What is the output?
- {7, 6, 5, 4, 3} b. {6, 5, 4 }
c. { 7, 6,
5,4} d. { 6, 5,4,3})
- What is the output of the following code segment?
int
X=10;
if ( X >= 10)
{
System.out.print(“ABC”);
}
- ABC b.
ABCXYZ
c.
ABCABC
d. no output
- Given below is a object calling a method add().
C.add(4,5,7.8);
Which of the following is the correct
form of defining the method?
- public int add()
c. public void add(int a,int b,double
c) - public void add(int a, double b, double
c) d. public int void
add()
- Write the output.
public class customer
{
public static void main(String [] args)
{
customer st = new customer();
st.print();
}
public static void print() {
int x = 9;
int y, z, calc;
y= 3;
z = 5;
calc = x-y+z;
System.out.println("Product: " + x*y);
System.out.println(calc); }
}
public class welcome
{
public static void main(String [] args)
{
welcome d = new welcome();
d.display();
}
public void display()
{int count;
for (count=6;count<=19;count=count+3)
System.out.println(count);}}
3. .
public class Game1
{
public static void main(String [] args)
{
Game1 s = new Game1();
s.simula();
}
public static void simula() {
int x;
x=3;
do
{
System.out.println(“You are learning
Methods!”);
x=x+1;
}while (x
<1;}}
Answer
Thank you for your question. Below are the answers to all questions. Please mention the question number to avoid copying the question.
===================================================================
Which statement in a for loop will correctly initialize more variables than one? c. for(a=1, b=2)
===================================================================
Method employee() returns a double value. Which one of the following methods is correct?
A. public double-employer()
===================================================================
Switch
===================================================================
Break
===================================================================
What will you replace with “void” in the method header if your method returns values?
Datatype of return value
===================================================================
Which form is best for defining an object’s characteristics?
d. classname_objectname=new classname()
===================================================================
public customer (String t. int y);
===================================================================
Question 22
main()
===================================================================
Which one of the following forms is correct for defining the method’s definition?
c. public void add(int a,int b,double c)
===================================================================
11.Write your output?
Below – for customers of class
Product: 27
11
===================================================================
Below is the output for each class.
6
9
12
15
18
===================================================================
3. Below is the output for class Game1.
You are learning methods!
===================================================================
Conclusion
Above is the solution for “Java Questions When creating a for loop, which statement will correctly initialize more than one variable?…“. We hope that you find a good answer and gain the knowledge about this topic of engineering.