C# Study Test
Practice tests to further your career.
Intro
The following study test contains practice certification questions along with a study link for each question.
These questions were prepared by Mike Prestwood and are intended to stress an important aspect. All our practice questions are intended to prepare you
specifically to earn your Prestwood certification and generally for passing any certification test as well as prepare you for
professional work.
Features:
Each question has a popup [Review] link.
Hover over answers to reveal correct answer.
17 Questions
Mouse over answers to reveal correct answer.
Beginner
4 Beginner Level Questions
Question #1: Multiple Choice
Which statement best describes C# constants?
Answer:
1. Declare constants with the literal keyword. All constants are part of a class (no global constants) but you can make a constant public and have access to it using ClassName.ConstantName.
2. Declare constants with the const keyword. All constants are part of a class (no global constants) but you can make a constant public and have access to it using ClassName.ConstantName.
3. Declare constants with the const keyword. For global constants, you can make use of a special global _CSGlobal class.
4. Declare constants with the const keyword. You can make constants part of a class or global to a namespace using the global keyword.
Question #2: Multiple Choice
Which of the following lines of code will compile?
Answer:
1. MessageBox .Show ( "d" );
2. MessageBox.Show("a");MessageBox.Show('b');
Question #3: True or False?
In C# you can declare and use a variable spelled the same but with a different case as in the following:
Int16 InvoiceNumber; Int16 INVOICENUMBER; InvoiceNumber = 1001; INVOICENUMBER = 1002; MessageBox.Show("" + InvoiceNumber); MessageBox.Show("" + INVOICENUMBER);
Answer:
Question #4: True or False?
If you do not create a developer defined constructor, C# creates an implicit constructor and initializes all member fields to their default values.
Answer:
Intermediate
6 Intermediate Level Questions
Question #5: Multiple Choice
Given the following two code snippets:
//Code Snippet 1 public class Cyborg : System.Object { private string cyborgName; public string CyborgName { get {return cyborgName;} set {cyborgName = value;} } } //Code Snippet 2 public class Cyborg : System.Object { public string CyborgName {get; set;} }
Answer:
1. Both are syntactically correct and accomplish the equivalent task.
2. Both are syntactically correct but accomplish completely different tasks.
3. Code snippet 1 is syntactically correct but code snippet 2 is not.
4. Code snippet 2 is syntactically correct but code snippet 1 is not.
Question #6: Multiple Choice
Given these 3 lines of code:
1. public class Cyborg {}2. public class Cyborg : System.Object {}3. public class Cyborg: Object {}
Which of the following statements is most accurate?
Answer:
4. All of the above. All three are equivalent.
5. None of the above. All three are not equivalent.
Question #7: Multiple Choice
Given this class:
public class Cyborg : System.Object { public virtual void IntroduceYourself() { MessageBox.Show("Hi, I do not have a name yet."); } }
Which of the following correctly creates an object instance and calls the IntroduceYourself method?
Answer:
1. Cyborg T1 = Cyborg.Create(); T1.IntroduceYourself();
2. Set T1 = new Cyborg(); T1.IntroduceYourself();
3. Cyborg T1 = new Cyborg(); T1.IntroduceYourself();
4. T1 As Cyborg = new Cyborg(); T1.IntroduceYourself();
5. T1 = new Cyborg(); T1.IntroduceYourself();
Question #8: True or False?
You can add abstract members ONLY to abstract classes using the abstract keyword. Then you override it in a descendant class with Override .
Answer:
Question #9: True or False?
You can set the visibility of a member field to any visibility including private , protected , public , internal or protected internal .
Answer:
Question #10: Multiple Choice
The method name of a constructor is?
Answer:
2. An unnamed method that uses the constructor keyword.
3. A method with the same name as the class and with no return value.
4. Any method name that uses the constructor keyword.
Advanced
7 Advanced Level Questions
Question #11: True or False?
You can overload static constructors.
Answer:
Question #12: Multiple Choice
When defining your own class, the default class visibility when none is specified is what?
Answer:
Question #13: True or False?
You can set the initial value of C# member property as follows:
pulic int VendorID = -1 {get; set;}
Answer:
Question #14: Multiple Choice
Given the following code snippet:
public class Cyborg { }
Answer:
1. The finalizer method name must be Finalize .
2. The finalizer method name must be Destroy .
3. The finalizer method name must be Dispose .
4. The finalizer method name must be ~Cyborg .
5. The finalizer method name can be any method name of your choosing so long as you use the finalizer keyword to indicate this is the finalizer method.
Question #15: Multiple Choice
You can put parts of a partial class where?
Answer:
1. In the same source file, namespace does not apply.
2. In the same source file, but all parts must be in the same namespace.
3. Anywhere within a namespace even in separate source files.
4. Each part must be in a separate namespace and in a separate source file.
Question #16: Yes or No?
Do all parts of a partial class have to be in the same source file?
Answer:
Question #17: True or False?
All parts of a partial class must be in the same namespace.
Answer: