Question

In the following program: public  class Problem2{     public static int sample(int x, int y){         int z;         .........

In the following program:

public  class Problem2{

    public static int sample(int x, int y){

        int z;

        ......

     }

    public static void  main(String[] args)

    {

         int a, b;

         ......

         sample(a,b);

    }

}

(1) What is the return type of sample?

(2) What are the local variables of sample?

(3) What are the parameters of sample?

(4) What are the arguments of sample?

(5) Is sample a per-object method? Or a per-class method?

(6) Is sample a public method, or private method?

0 0
Add a comment Improve this question Transcribed image text
Answer #1
(1) What is the return type of sample?
int 

(2) What are the local variables of sample?
z

(3) What are the parameters of sample?
x and y of types int

(4) What are the arguments of sample?
a and b

(5) Is sample a per-object method? Or a per-class method?
per-class method

(6) Is sample a public method, or private method?
public
Add a comment
Know the answer?
Add Answer to:
In the following program: public  class Problem2{     public static int sample(int x, int y){         int z;         .........
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
  • Java Inner class class Outer {    private int x=10;    private static int y=20 ;...

    Java Inner class class Outer {    private int x=10;    private static int y=20 ;    publics void M1( ) {          int z=30;        class Inner           {             public void M2()              {                                                                              Sytem.out.println(“sum: ”+ (x+y+z));               }         } Inner i=new Inner();    i.M2() ; /// first call    i.M2(); // second call i.M2(); // third call }   // end of M1        publics static void main(String[] args)       {           Outer O = new...

  • 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...

  • Analyze the following code: public class Test { private int t; public static void main(String[] args)...

    Analyze the following code: public class Test { private int t; public static void main(String[] args) { int x; System.out.println(t); } } The variable t is private and therefore cannot be accessed in the main method. The program compiles and runs fine. t is non-static and it cannot be referenced in a static context in the main method. The variablet is not initialized and therefore causes errors. The variable x is not initialized and therefore causes errors.

  • What is the output of this program? class A { public int i; private int j;...

    What is the output of this program? class A { public int i; private int j; } class B extends A { void display() { super.j = super.i + 1; System.out.println(super.i + " " + super.j); } } class Inheritance { public static void main(String args[]) { B obj = new B(); obj.i=1; obj.j=2; obj.display(); } } Java language!! // include explanation!

  • output What is the output of the following: class Access public int x; private int y...

    output What is the output of the following: class Access public int x; private int y public void cal(int x, int y) { this.x = x + 1; this.y = y; } public void print() { System.out.print(""+y); } } class AccessSpecifier { public static void main(String args[]) { Access obj = new Access(); obj.cal(2, 3); System.out.print(obj.x); obj.print(); } } 33 Compilation error 23 None of the available choices Runtime error

  • Analyze the following code: public class Test { private int t; public static void main(String[] args)...

    Analyze the following code: public class Test { private int t; public static void main(String[] args) { int x; System.out.println(t); } } t is non-static and it cannot be referenced in a static context in the main method. The program compiles and runs fine. The variable t is not initialized and therefore causes errors. The variable x is not initialized and therefore causes errors.

  • What output is produced by the following program? public class MysteryNums public static void main(String[] args)...

    What output is produced by the following program? public class MysteryNums public static void main(String[] args) - int x = 12; int y = x - 3; 3, sentence (y, x + y); . public static void sentence (int numi, int num2) { 4: System.out.println(num1 + " + num2);

  • skeleton: import java.util.*; public class Point3D{ private int x,y,z; Point3D(int a, int b, int c){ x = a; y = b; z = c; } public int x(){ return x; } public int y(){ return y; } public in...

    skeleton: import java.util.*; public class Point3D{ private int x,y,z; Point3D(int a, int b, int c){ x = a; y = b; z = c; } public int x(){ return x; } public int y(){ return y; } public int z(){ return z; } public String toString(){ return "("+x+","+y+","+z+")"; } } Question1Test.java import java.util.*; public class Question1Test { public static void main(String[] args){ MyHashList<Point3D> lst = new MyHashList<Point3D>(1000); } } a) A class Point3D is given. Re-write this class so that...

  • What is the output of the following code? public class Test { pub be static void...

    What is the output of the following code? public class Test { pub be static void main(String() args) { Object o 1 -new Object(); Object o2 = new Object(); System out.print((o1 = o2) + "" + (o1 equals(o2))); } } A. false false B. true true C. false true D. true false Analyze the following code. //Program 1: public class Test { public static void main(String[] args) { Object circle 1 = new Circle(); Object circle2 = new Circle(); System...

  • What is the output of following program: public class Test{ public static void main(String[] args) {...

    What is the output of following program: public class Test{ public static void main(String[] args) { A a = new A(): a method B(): } } class A{ public A(){ System out println("A's constructor is executed"): } public void method(){ System out printin ("methodA is executed"): } public void methodAB(){ System out printin ("As methodAB is executed"): } } class B extends A { private int num = 0: public B (){ super(): System out printin ("B's constructor is executed"):...

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