Submitted by c-admin on Tue, 05/28/2019 - 00:51
Which of the following correctly defines a method named stringProcessor that can be called by other programmers as follows: stringProcessor(str1) or stringProcessor(str1, str2) or stringProcessor(str1, str2, str3),
where str1, str2, and str3 are references to Strings.
Select 1 option
A. public void stringProcessor(...String){
}
B. public void stringProcessor(String... strs){
}
C. public void stringProcessor(String[] strs){
}
D. public void stringProcessor(String a, String b, String c){
}
E. Three separate methods need to be written.
Submitted by c-admin on Tue, 05/28/2019 - 00:48
Which of the following are valid at line 1?
public class X{
//line 1: insert code here.
}
Select 2 options
A. String s;
B. String s = 'asdf';
C. String s = 'a';
D. String s = this.toString();
E. String s = asdf;
Submitted by c-admin on Tue, 05/28/2019 - 00:38
Consider the following class:
public class Test{
public int id;
}
Which of the following is the correct way to make the variable 'id' read only for any other class?
Select 1 option
A. Make 'id' private.
B. Make 'id' private and provide a public method getId() which will return its value.
C. Make 'id' static and provide a public static method getId() which will return its value.
D. Make id 'protected'.
Submitted by c-admin on Tue, 05/28/2019 - 00:34
Consider the following class...
class TestClass{
int x;
public static void main(String[] args){
// lot of code.
}
}
Select 1 option
A. By declaring x as static, main can access this.x
B. By declaring x as public, main can access this.x
C. By declaring x as protected, main can access this.x
D. main cannot access this.x as it is declared now.
E. By declaring x as private, main can access this.x
Submitted by c-admin on Tue, 05/28/2019 - 00:31
Given:
class Triangle
{
public int base;
public int height;
private static double ANGLE;
public static double getAngle();
public static void Main(String[] args)
{
System.out.println(getAngle());
}
}
Identify the correct statements:
Select 1 option
A. It will not compile because it does not implement setAngle method.
B. It will not compile because ANGLE cannot be private.
C. It will not compile because getAngle() has no body.
D. It will not compile because ANGLE field is not initialized.
E. It will not compile because of the name of the method Main instead of main.
Pages