Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Java 

[HELP - still needed] Some quick questions - beginner level [JAVA]

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:
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;
}}
I will do this for you bro. Im in train now, will edit this post in few minutes with the answers.

EDIT:

Came to the conclusion Im not sure I would be given the correct answers. Im sorry.
You could easily answer these by writing code and checking the results.
(Jan 11, 2017 08:34 AM)g4143 Wrote:  You could easily answer these by writing code and checking the results.

Sadly, I would have to enter way too much code to understand it. (Just this one won't be enough and it will give either an empty result or an error)..

I do have a lot of other things to study for. Thank you for the suggestion, but I would love if someone can help me out on this one.
1. B
2. A
3. B
4. C
5. A
6. A

As others said, you're better off writing the code yourself. Stackoverflow and Javadocs are pretty helpful too.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Java] by x1029May 1, 2015 07:09 AM 20 738 May 1, 2015 07:09 AM
Last Post: MrOrang
[Python] by SuperHydraFeb 17, 2015 11:30 PM 9 271 Feb 17, 2015 11:30 PM
Last Post: clark.dll
[Python] by MesslOct 22, 2014 09:57 PM 9 334 Oct 22, 2014 09:57 PM
Last Post: glob