01:198:111 Lecture Notes - Lecture 7: Object-Oriented Programming

27 views2 pages
Verified Note

Document Summary

Users of car do not need to understand how the car works normally. Think of a blueprint of a house. Many houses can be built using the same blueprint. Always private instance variables for accessor type public class student { private string lname; private string fname; private double gpa; private int studentid; } An object stores its data in instance variables. The class declaration specifies the instance variables. They are the attributes of the object. Student default constructor definition public student() { lname= doe fname= john . Constructor initializes the instance of the private class. Student constructor definition public class student (string last, string first) { private string lname = last; private string fname = first; private double gpa = 0. 0; private int studentid = 0; } Constructor body is executed when new object is created with new. Statements in constructor body will set the internal data of the object that is being constructed.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents