Those are JAVA OOP questions, Please help 1. Which of the following statements i
ID: 3758020 • Letter: T
Question
Those are JAVA OOP questions, Please help
1.
Which of the following statements is true?
A static variable cannot have its value set in a constructor
A static variable must be declared final
An instance variable can't be declared final
A static method can't access an instance variable
Only a static method can access a static variable
2.
Which statements are most accurate regarding the following classes?
class C {
private int s;
protected int t;
}
class D extends C {
private int x;
protected int y;
// some methods omitted
}
In the class D, an instance method can only access x, y.
In the class D, an instance method can only access t, y.
In the class D, an instance method can only access t, x, y.
In the class D, an instance method can access s, t, x, y.
3.
Which of the following prototypes shows that a Cube subclass is derived from a superclass called Square?
class Square extends Cube
class Cube derived Square
class Cube extends Square
class Square derived Cube
4.
Analyze the following code:
public class SampleApp {
public static void main(String[] args) {
String s = new String("Hello World!");
Object o = s;
String d = (String)o;
}
}
Which of the following is true?
When assigning s to o in Object o = s, a new object is created.
When casting o to s in String d = (String)o, a new object is created.
When casting o to s in String d = (String)o, the contents of o is changed.
s, o, and d reference the same String object.
5.
Which of the following always needs to start with a Capital letter?
class names
objects and class names
fields
data types and fields
6.
If classes Student, Staff and Faculty extend class Person, which one makes sense:
Faculty[] faculties={new Person(), new Staff(), new Student()};
Staff[] staff={new Person(), new Faculty(), new Student()};
Person[] persons={new Faculty(), new Staff(), new Student()};
7.
If none of the private/protected/public is specified for a member, that member ...
is accessible publicly
is only accessible by other classes of the same package
is only accessible from within the class
is accessible by the class and its subclasses
A.A static variable cannot have its value set in a constructor
B.A static variable must be declared final
C.An instance variable can't be declared final
D.A static method can't access an instance variable
E.Only a static method can access a static variable
Explanation / Answer
1) A
2) C
3) C
4) A
5) A
6) C
7) A
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.