Practice C# 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.cs
B.cs
-
-
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:
Console.WriteLine("A: "+a+"\n");
Implement the function that will allow this.
Now imagine that I have these two classes:
SubA.cs and
SuperA.cs
-
In order to allow SubA to directly access instance variable number,
what keyword do I need to use when it is declared?
-
What does the line base(x*2) do?
-
What is the output of running main in SubA?
-
How does the computer decide between calling SuperA or SubA's version of getNumber?
-
How does the computer decide between calling SuperA or SubA's version of setNumber?
-
Explain why the following line of code is not allowed: SubA a1 = new SuperA(7);