Hack Forums
[Java] [HELP - still needed] Some quick questions - beginner level [JAVA] - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Java] [HELP - still needed] Some quick questions - beginner level [JAVA] (/showthread.php?tid=5520542)



[HELP - still needed] Some quick questions - beginner level [JAVA] - crossera - Jan 11, 2017

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;
}}



* - Mohinder - Jan 11, 2017

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.


* - g4143 - Jan 11, 2017

You could easily answer these by writing code and checking the results.


* - crossera - Jan 11, 2017

(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.


* - Hitmaster - Jan 11, 2017

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.