Question

Java Questions When creating a for loop, which statement will correctly initialize more than one variable?...

  1. Java Questions
    1. When creating a for loop, which statement will correctly initialize more than one variable?

a.

for a=1, b=2

c.

for(a=1, b=2)

b.

for(a=1; b=2)

d.

for(a = 1&& b = 2)

    1. A method employee() is returning a double value. Which of the following is the correct way of defining this method?
  1. public double employee()                                    c. public int employee()
  2. public double employee(int t)                  d. public void employee()
    1. The ____ statement is useful when you need to test a single variable against a series of exact integer, character, or string values.

a.

Switch

c.

else

b.

If

d.

Break

  1. You can leave out the ____ statements in a switch structure.

a.

Break

c.

if

b.

Switch

d.

Case

    1. If your method is returning values ,what will replace the word "void" in your method header.
  1. return                                                     c. datatype of return value
  2. void                                                                     d. null
    1. Which is the correct for form for defining an object?
  1. classname objectname=new classname
  2. objectname classname=new objectname()
  3. d. ojectname,object name=new() ob
  4. classname objectname=new classname()
    1. Given below is a object creation statement for a class customer.

customer c=new customer(”ALI”,5)

   Which will be the correct way of defining a constructor?

  1. public void customer()                         c. public customer(int a, String t)
  2. public customer(String t, int y) d. public void customer() )

22. All Java application programs must have this method to run.

  1. hello()                                                         c. start()            
  2. main(),                                                        d. add()
  1. Examine the following code:

for(count = 7 ;count> =3; count =count-1)

{

System.out.print(count+” “); }

What is the output?

  1. {7, 6, 5, 4, 3}       b. {6, 5, 4 }       c. { 7, 6, 5,4}      d. { 6, 5,4,3})
  1. What is the output of the following code segment?

                 int X=10;                                                           

                 if ( X >= 10)

                 {

                     System.out.print(“ABC”);

                 }

  1. ABC        b. ABCXYZ                 c. ABCABC                 d. no output
  1. 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?

  1. public int add()                                            c. public void add(int a,int b,double c)
  2. public void add(int a, double b, double c)        d. public int void add()
  1. 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;}}              

    0 0
    Add a comment Improve this question Transcribed image text
    Answer #1

    Thanks for the question, below are the answers to all the questions. Going forward, please do mention the question number so that I dont need to copy the question.

    ===================================================================

    When creating a for loop, which statement will correctly initialize more than one variable?
    c. 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. public double employee()

    ===================================================================
    switch

    ===================================================================

    break

    ===================================================================

    If your method is returning values ,what will replace the word "void" in your method header.
    datatype of return value

    ===================================================================

    Which is the correct for form for defining an object?
    d. classname objectname=new classname();

    ===================================================================
    public customer(String t, int y);

    ===================================================================

    Question 22
    main()

    ===================================================================
    Which of the following is the correct form of defining the method?
    c. public void add(int a,int b,double c)

    ===================================================================

    11 .Write the output?
    Output for class customer is below -
    Product: 27
    11

    ===================================================================
    Output for class welcome is below -
    6
    9
    12
    15
    18

    ===================================================================

    3. Output for class Game1 is below -
    You are learning Methods!
    ===================================================================

    Add a comment
    Know the answer?
    Add Answer to:
    Java Questions When creating a for loop, which statement will correctly initialize more than one variable?...
    Your Answer:

    Post as a guest

    Your Name:

    What's your source?

    Earn Coins

    Coins can be redeemed for fabulous gifts.

    Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
    Similar Homework Help Questions
    • 1) Consider the following Java program: 1 public class HelloWorld { 2     // My first program!...

      1) Consider the following Java program: 1 public class HelloWorld { 2     // My first program! 3     public static void main(String[] args) { 4         System.out.println("Hello, World!"); 5     } 6 } What is on line 1? a. a variable declaration b. a statement c. a method (subroutine) definition d. a comment e. a class definition 2) Which one of the following does NOT describe an array? a. It can be used in a for-each loop. b. It has a numbered sequence...

    • 1. What is the output when you run printIn()? public static void main(String[] args) { if...

      1. What is the output when you run printIn()? public static void main(String[] args) { if (true) { int num = 1; if (num > 0) { num++; } } int num = 1; addOne(num); num = num - 1 System.out.println(num); } public void addOne(int num) { num = num + 1; } 2. When creating an array for primitive data types, the default values are: a. Numeric type b. Char type c. Boolean type d. String type e. Float...

    • 12. Predict the output generated at the marked println lines in the following program. The program...

      12. Predict the output generated at the marked println lines in the following program. The program makes use of the class Employee that is also given. Please enter your answers in the space provided below the code. public class Employee { private String name; private double salary; public Employee(String name, double salary) { this.name = name; this.salary = salary; } public String getName() { return name; } public double getSalary() { return salary; } public void raiseSalary(double percent) { double...

    • please edit my java code perferably on jgrasp version 50.0 , wont complie correctly :( the...

      please edit my java code perferably on jgrasp version 50.0 , wont complie correctly :( the program is supposed to read from my input file and do the following        1) print out the original data in the file without doing anything to it.        2) an ordered list of all students names (last names) alphabetically and the average GPA of all student togther . 3) freshman list in alphabeticalorder by last name with the average GPA of the freshmen...

    • 2. Write a counter controlled loop to solve the following problems. Each one will involve an...

      2. Write a counter controlled loop to solve the following problems. Each one will involve an array (MinMax.java) Read in 25 ints from the keyboard, and store them in an array. Then, find the maximum and minimum values in such an array, and display them on the screen. public class Array-Assignment { public static void main(String [] args) {     int [] x = new int[3];     int [] y = {3, 5, 9, 2};     x[2] = y[3];    ...

    • Java will be printed 10. can you explain step by step why? public class WhatsPrinted2 {...

      Java will be printed 10. can you explain step by step why? public class WhatsPrinted2 { public static void whatHappens(int A[]) { int []B = new int[A.length]; for (int i=0; i<A.length; i++) { B[i]=A[i]*2; } A=B; } public static void main(String args[]) { int A[] = {10,20,30}; whatHappens(A); System.out.println(A[0]); } } will print 10. explain how it's works. Thanks public class WhatsPrinted3 { public static int[] whatHappens(int A[]) { int []B = new int[A.length]; for (int i=0; i<A.length; i++) {...

    • The method m() of class B overrides the m() method of class A, true or false?...

      The method m() of class B overrides the m() method of class A, true or false? class A int i; public void maint i) { this.is } } class B extends A{ public void m(Strings) { 1 Select one: True False For the following code, which statement is correct? public class Test { public static void main(String[] args) { Object al = new AC: Object a2 = new Object(); System.out.println(al); System.out.println(a): } } class A intx @Override public String toString()...

    • Modify the objectstudent JAVA program to add a private variable zipcode, you must also add setters...

      Modify the objectstudent JAVA program to add a private variable zipcode, you must also add setters and getter methods for the new variable and modify the toString method. The objectstudent program is in this weeks module, you can give it a default value of 19090. class Student { private int id; private String name; public Student() { id = 8; name = "John"; } public int getid() { return id; } public String getname() { return name; } public void...

    • Java Assignment Calculator with methods. My code appears below what I need to correct. What I...

      Java Assignment Calculator with methods. My code appears below what I need to correct. What I need to correct is if the user attempts to divide a number by 0, the divide() method is supposed to return Double.NaN, but your divide() method doesn't do this. Instead it does this:     public static double divide(double operand1, double operand2) {         return operand1 / operand2;     } The random method is supposed to return a double within a lower limit and...

    • I need help on creating a while loop for my Java assignment. I am tasked to...

      I need help on creating a while loop for my Java assignment. I am tasked to create a guessing game with numbers 1-10. I am stuck on creating a code where in I have to ask the user if they want to play again. This is the code I have: package journal3c; import java.util.Scanner; import java.util.Random; public class Journal3C { public static void main(String[] args) { Scanner in = new Scanner(System.in); Random rnd = new Random(); System.out.println("Guess a number between...

    ADVERTISEMENT
    Free Homework Help App
    Download From Google Play
    Scan Your Homework
    to Get Instant Free Answers
    Need Online Homework Help?
    Ask a Question
    Get Answers For Free
    Most questions answered within 3 hours.
    ADVERTISEMENT
    ADVERTISEMENT
    ADVERTISEMENT