Given the SampleClass, what is the output of this code segment SampleClass s = new SampleClass(); s.sampleMethod(4.4, 4); public class SampleClass { public void sampleMethod(int a, double b) { System.out.println("Method 1"); } public void sampleMethod(double b, int a) { System.out.println("Method 2"); } }
A. Method 1
B. Method 2
C. Method 1 Method 2
D. Method 2 Method 1
E. Compiler error
查看答案
Static methods have access to which of the following (Choose all that apply.)
A. Static variables
B. Instance variables
C. Standard methods
D. Static Methods
E. None of the above
Given the class FloatNumber and method addHalf, what is the output if the following code segment is executed public class FloatNumber { float number; public FloatNumber(float number { this.number = number; } floatgetNumber( { retum number; } void setNumber(float number) { this.number = number; } } void addHalf(FloatNumber value) { value.setNumber(value.getNumber()+(value.getNumber()/2f)); } /* CODE SEGMENT */ FloatNumber value = new FloatNumber(1f); addHalf(value); System.out.println("value ="+value.getNumber());
A. value = 1
B. value = 1.5
C. value = 2
D. value = 0
You need to create a class to store information about books contained in a library. What variable scope is best suited for the variable that will store the title of a book
A. Local variable
B. Static variable
C. Global variable
D. Method parameter
E. Instance variable
A method needs to be created that accepts an array of floats as an argument and does not return any variables. The method should be called setPoints. Which of the following method declarations is correct
A. setPoints(float[] points) {...}
B. void setPoints(float points) {...}
C. void setPoints(float[] points) {...}
D. float setPoints(float[] points) {...}