Jan 11, 2017 08:24 AM
(This post was last modified: Jan 11, 2017 08:59 AM by crossera.)
Question were given as an example of what we could have on an exam. I answered most of them myself. However for the questions below I either can not answer them or I am not sure in my answer. They are pretty basic and I would really appreciate if someone can help me out.
1.Constructor of class A would be available for:
a) everyone
b) inherited classes
c) nobody
Code below:
2.Constructor of class A would call constructor of:
a) class B
b) class Object
c) there is mistake in the code
Code below:
3. Attribute x have default value would be available for:
a) null
b) 0
c) mistake in the code
Code below:
4. Method getX returns value:
a) 0
b) null
c) there is mistake
5. Code creates:
a) Object of type Student
b) Class of type Student
c) Interface of type Student
6.Method setX sets value of:
a) local variable x
b) attribute x
c) there is mistake
1.Constructor of class A would be available for:
a) everyone
b) inherited classes
c) nobody
Code below:
Code
class A extends B {
public A() {
super();
} }2.Constructor of class A would call constructor of:
a) class B
b) class Object
c) there is mistake in the code
Code below:
Code
class A extends B {
public A() {
super();
} }3. Attribute x have default value would be available for:
a) null
b) 0
c) mistake in the code
Code below:
Code
class A {
private int x;
public A() {
} }4. Method getX returns value:
a) 0
b) null
c) there is mistake
Code
class A {
private int x;
public int getX() {
return
} }5. Code creates:
a) Object of type Student
b) Class of type Student
c) Interface of type Student
Code
// .......
Student s = new Student();
// .....6.Method setX sets value of:
a) local variable x
b) attribute x
c) there is mistake
Code
abstract class A {
private int x;
void setX (int v) {
int x; x=v;
}}

