Practice Java questions
-
I want to implement a class named MyClass. What shall I name
the file?
-
What line do I type to compile the code on a unix-based machine?
-
What line do I type to run the code on a unix-based machine?
Consider the following code:
A.java
B.java
-
-
What type of function is public A(int x)?
-
What type of function is public int getNumber()?
-
What is the output from running main in A?
-
I would like to be able to print out like this:
System.out.println("A: "+a+"\n");
Implement the function that will allow this.
Now imagine that I have a class that extends A.
SubA.java
-
In order to allow SubA to directly access instance variable number,
what keyword do I need to use?
-
What does the line super(x) do?
-
What happens if there isn't a call to super?
-
What is the output of running main in SubA?