Professional Documents
Culture Documents
Lec 1 (Introduction)
Lec 1 (Introduction)
Herat University
Computer Science Faculty
Lecturer: Azita Azimi
Date: May 28, 2021
INTRODUCTION TO JAVA PROGRAMMING (11TH ED.) Y. DANIEL LIANG 2
Course Introduction
¡ Lecture presentation
¡ Exercises:
¡ Assignments
¡ Debriefing
¡ Q &A
¡ Tutorial
¡ Q &A
¡ Panel discussions
¡ For many years the structured programming model was prevalent in the software
industry.
¡ But structured programming is a program development methodology. It does not
deal with the real-world problem at the origin of every software project
¡ We can say that structured programming focuses on the solution-set of a software
project. But defining, and modeling the problem-set is one of the major blocks of
software development,
¡ The object-oriented approach focuses on this problem set.
¡ The following are the most important claims of the object-oriented approach:
1. The OO model can be understood by clients and software users with no technical
knowledge of programming or computers. For this reason, program analysis and design
methods based on object-orientation facilitate communications with clients.
2. Real-world problems can be modeled in object-oriented terms.
3. Object-oriented programming languages promote and facilitate code reuse. Reusing code
increases programmer productivity.
4. The need to modify program behavior with minimal changes to existing code.
¡ State: ¡ Behavior:
¡ four wheels, ¡ driving,
¡ four doors, ¡ Brake,
¡ a car radio ¡ slowing down,
¡ In real world, you often have many objects of the same kind.
¡ Objects of the same kind are similar and you can create a prototype for those
objects.
¡ A prototype of objects is called a class.
¡ Using object oriented terminology, we say that your car object is an instance of the
class of cars.
¡ Object is a variable of user defined type called class.
¡ A class is a prototype, that defines the variables and the methods common to all
objects of a certain kind.
¡ Objects ¡ Classes
¡ has state + behavior ¡ we can implement state and behavior
¡ has specific state + behavior ¡ has specifiation of state and behavior
¡ Example:
class Student{
// member variables go here
public Student(){
// This constructor does not parameter
}
}
INTRODUCTION TO JAVA PROGRAMMING (11TH ED.) Y. DANIEL LIANG 31
Overloaded Constructor
¡ Overloaded Constructor
¡ As any other method, a constructor can get parameters.
¡ This parameters can be used to set initial values of the objects properties.
¡ A constructor with arguments is called the Overload constructor.
¡ Example:
class Student{
// member variables go here
public Student(String name){
// This constructor has one parameter, name.
}
}
INTRODUCTION TO JAVA PROGRAMMING (11TH ED.) Y. DANIEL LIANG 32
Constructor usage