Chapter3_2-ObjectsAndInstanceAtributes

Instancevariablenameattributename course1studentname

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: tes’ values of a specific object. instanceVariableName.attributeName course1.StudentName= “Majed AlKebir“; course2.StudentName= “Fahd AlAmri “; course2 course1 Object: Course studentName Fahd AlAmri courseCode Page 15 Object: Course studentName Majed AlKebir courseCode Dr. S. GANNOUNI & Dr. A. TOUIR Introduction to OOP Object vs. Class • A class could be considered as a set of objects having the same characteristics and behavior. • An object is an instance of a class. Page 16 Dr. S. GANNOUNI & Dr. A. TOUIR Introduction to OOP class Course { // Instance attributes public String studentName; public String courseCode ; } public class CourseRegistration { public static void main(String args) { Course course1, course2; //Create and assign values to course1 course1 = new Course( ); course1.courseCode= new String(“CSC112“); course1.studentName= new String(“Majed AlKebir“); //Create and assign values to course2 course2 = new Course( ); course2.courseCode= new String(“CSC107“); course2.studentName= new String(“Fahd AlAmri“); System.out.println(course1.studentName + &quo...
View Full Document

This document was uploaded on 03/03/2014.

Ask a homework question - tutors are online