C# Module 4 Questions And Answers.
C# Module 4 Questions And Answers. Class - CORRECT ANSWER -Template -Defines structure for all objects that are going to be of that class type -When define a class, describe its attributes (fields) in terms of data and behaviors (methods) in terms of what kind of things it can do -By abstracting attributes and behaviors, can create a class to serve as a template from which many objects of the same type can be instantiated Access modifiers - CORRECT ANSWER -Classes: public, other classes can reuse class with different applications -Data members: private, only accessed within body of the class in which they are declared -Methods that access this data: public Fields - CORRECT ANSWER -"private data type nameOfField" -Represent the state of an object -Blueprint in terms of what kind of data will be associated with each object -Visible to all members of the class Constructors - CORRECT ANSWER -"public ClassName (declare variables) {variables = fields}" -Special types of methods used to create objects -Don't return a value, but don't include keyword void -Use same name as the class name -Overloaded: same identifiers but different signatures (number of arguments) -Public access: other classes can instantiate objects of this class -Provide values for data members: arguments to the constructor method (new variables assigned to value of fields) or hard coded into body
Written for
- Institution
-
Harvard University
- Module
-
CS50
Document information
- Uploaded on
- May 26, 2024
- Number of pages
- 3
- Written in
- 2023/2024
- Type
- Exam (elaborations)
- Contains
- Questions & answers
Subjects
- cs50
-
c module 4 questions and answers
Also available in package deal