Object Oriented Programming Fundamentals and Assessments Overview

object oriented programming n.w
1 / 39
Embed
Share

Explore the fundamentals of object-oriented programming, such as classes, inheritance, GUI basics, and more. Dive into Java programming with essential books and references recommended by experts. Learn about the weighting of assessments, including exams and practical projects. Understand the Java language specification, API, JDK, and IDE for developing and testing Java programs effectively.

  • Java Programming
  • Object-Oriented
  • Fundamentals
  • Assessments
  • Java IDE

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Object Oriented programming Chapter 1:7 Fundamentals of Programming Instructor: Dr. Essam H. Houssein Dr Mona A. S. Ali 1

  2. A. Content Subject Lec # Time Chapter 1:7 Fundamentals of Programming Lec (1): Week 1 Chapter 8 Objects and Classes Lec (2): Week 2 Chapter 9 Strings and Text I/O Lec (3): Week 3 Chapter 10 Thinking in Objects Lec (4): Week 4 Chapter 11 Inheritance and Polymorphism Lec (5): Week 5 Chapter 13 Exception Handling Lec (6): Week 6 Chapter 14 Abstract Classes and Interfaces Lec (7): Week 7 Chapter 19 Binary I/O Lec (8): Week 8 Chapter 12 GUI Basics Lec (9): Week 9 Chapter 15 Graphics Lec (10): Week 10 Chapter 16 Event-Driven Programming Lec (11): Week 11 GUI & Menus & Multithreading Lec (12): Week 12 Ch 39-40 Servlets & JSP Lec (13): Week 13 Ch 19 Binary I-O Lec (14): Week 14 2

  3. A.List of References: Essential Book: Introduction to Java Programming Comprehensive Version, 9th Edition, Y. Daniel Liang, Prentice Hall, 2013. Recommended Book: Java How to Program, 10th Edition , P. Deitel, H. Deitel , Prentice Hall, 2012. Course Coordinator:Dr. Essam H. Houssein Dr. Mona A.S. Ali 3

  4. Weighting of Assessments: Final-Term Examination (90 Degree) Mid-Term Examination (10 Degree) Practical and Oral Examination (Project) (20 Degree) Other types of assessment (Assignments) (5 Degree) 125 4

  5. 5

  6. 1.6 The Java Language Specification, API, JDK, and IDE The Java language specification is a technical definition of the language that includes the syntax and semantics of the Java programming language. The application program interface (API) contains predefined classes and interfaces for developing Java programs. 6

  7. Java Development Toolkit JDK consists of a set of separate programs, each invoked from a command line, for developing and testing Java programs. Besides JDK, you can use a Java development tool (e.g., Net- Beans, Eclipse, and TextPad) software that provides an integrated development environment (IDE) 7

  8. 2.3 Reading Input from the Console Console input is not directly supported in Java, but you can use the Scanner class to create an object to read input from System.in, as follows: Scanner input = new Scanner(System.in); 8

  9. Augmented Assignment Operators 9

  10. 2.4 Identifiers As you see in Listing 2.3, ComputeAverage, main, input, number1, number2, number3, and so on are the names of things that appear in the program. Such names are called identifiers. All identifiers must obey the following rules: 2.8.2 Numeric Literals A literal is a constant value that appears directly in a program. For example, 34 and 0.305 are literals in the following statements: int numberOfYears = 34; 10

  11. System.out.println( (int) 1.7 ) ; 2.13 Character Data Type and Operations The character data type, char, is used to represent a single character. A character literal is enclosed in single quotation marks. Consider the following code: char letter = 'A'; char numChar = '4'; 11

  12. 2.15 The String Type The char type represents only one character. To represent a string of characters, use the data type called String. For example, the following code declares the message to be a string with value Welcome to Java . String message = "Welcome to Java"; 12

  13. 2.16.3 Proper Indentation and Spacing Indentationis used to illustrate the structural relationships between a program s components or statements. Java can read the program even if all of the statements are in a straight line, but humans find it easier to read and maintain code that is aligned properly. Indent each subcomponent or statement at least two spaces more than the construct within which it is nested. A single space should be added on both sides of a binary operator, as shown in the following statement: 13

  14. 2.16.4 Block Styles A block is a group of statements surrounded by braces. There are two popular styles, next-line style and end-of-line style, as shown below. 14

  15. 2.17 Programming Errors 2.17.1 Syntax Errors Errors that occur during compilation are called syntax errors or compile errors. 2.17.2 Runtime Errors Runtime errors are errors that cause a program to terminate abnormally. 2.17.3 Logic Errors Logic errors occur when a program does not perform the way it was intended to. Errors of this kind occur for many different reasons. Logic errors are called bugs. The process of finding and correcting errors is called debugging. 15

  16. 3.4.1 One-Way if Statements A one-way if statement executes an action if and only if the condition is true. The syntax for a one-way if statement is shown below: if (boolean-expression) { statement(s); } 16

  17. 3.6 Two-Way if Statements A one-way if statement takes an action if the specified condition is true. If the condition is false, nothing is done. But what if you want to take alternative actions when the condition is false? You can use a two-way if statement. The actions that a two-way if statement specifies differ based on whether the condition is true or false. Here is the syntax for a two-way if statement: if (boolean-expression) { statement(s)-for-the-true-case; } else { statement(s)-for-the-false-case; } 17

  18. 18

  19. 3.15 switch Statements The if statement in Listing 3.6, ComputeTax.java, makes selections based on a single true or false condition. There are four cases for computing taxes, which depend on the value of status. To fully account for all the cases, nested if statements were used. Overuse of nested if statements makes a program difficult to read. Java provides a switch statement to handle multiple conditions efficiently. You could write the following switch statement to replace 19

  20. the nested if statement in Listing 3.6: switch (status) { case 0: compute taxes for single filers; break; case 1: compute taxes for married filing jointly; break; case 2: compute taxes for married filing separately; break; case 3: compute taxes for head of household; break; default: System.out.println("Errors: invalid status"); System.exit(0); } 20

  21. 4.2 The while Loop The syntax for the while loop is as follows: while (loop-continuation-condition) { // Loop body Statement(s); } 21

  22. 4.3 The do-while Loop The do-while loop is a variation of the while loop. Its syntax is given below: do { // Loop body; Statement(s); } while (loop-continuation-condition); 22

  23. 4.4 The for Loop In general, the syntax of a for loop is as shown below: for (initial-action; loop-continuation-condition; action-after-each-iteration) { // Loop body; Statement(s); } 23

  24. 5.2 Defining a Method The syntax for defining a method is as follows: modifier returnValueType methodName(list of parameters) { // Method body; } 24

  25. 25

  26. 26

  27. 5.3.1 Call Stacks 27

  28. 5.3.1 Call Stacks 28

  29. 5.8 Overloading Methods that is, two methods have the same name but different parameter lists within one class. 5.9 The Scope of Variables The scope of a variable is the part of the program where the variable can be referenced. A variable defined inside a method is referred to as a local variable. 29

  30. 30

  31. 5.12 Method Abstraction Method abstraction is achieved by separating the use of a method from its implementation. The client can use a method without knowing how it is implemented. The details of the implementation are encapsulated in the method and hidden from the client who invokes the method. This is known as information hiding or encapsulation. 31

  32. double[] myList; // Declaring Array Variables double[] myList = new double[4]; // Creating Arrays This statement declares an array variable, myList, creates an array of ten elements of double type, and assigns its reference to myList. The size of an array cannot be changed after the array is created. 32

  33. 6.5 Copying Arrays Often, in a program, you need to duplicate an array or a part of an array. In such cases you could attempt to use the assignment statement (=), as follows: list2 = list1; Another approach is to use the arraycopy method in the java.lang.System class to copy arrays instead of using a loop. The syntax for arraycopy is shown below: arraycopy (sourceArray, src_pos, targetArray, tar_pos, length); 33

  34. 34

  35. What is the difference between pass-by-value and pass-by-sharing? public class Test { public static void main(String[] args) { int x = 1; // x represents an int value int[] y = new int[10]; // y represents an array of int values m(x, y); // Invoke m with arguments x and y System.out.println("x is " + x); System.out.println("y[0] is " + y[0]); } public static void { number = 1001; // Assign a new value to number numbers[0] = 5555; // Assign a new value to numbers[0] } } 35

  36. 6.9 Searching Arrays 6.10 Sorting Arrays 6.11 The Arrays Class The java.util.Arrays class contains various static methods for sorting and searching arrays, comparing arrays, and filling array elements. These methods are overloaded for all primitive types. double[] numbers = {6.0, 4.4, 1.9, 2.9, 3.4, 3.5}; java.util.Arrays.sort(numbers); // Sort the whole array java.util.Arrays.binarySearch(list, 11)); 36

  37. int[][] matrix; matrix = new int[5][5]; matrix[2][1] = 7; 37

  38. Assignment (1): Write a program that: 1- Displaying Prime Numbers Page 137 2- Determining Leap Year Page 90 3- Displaying Calendars Page 151 4- Displaying Twin Primes Page 195 5- Counting the Occurrence of each Letter page 212 6- Counting of Occurrence of Numbers Page 227 38

  39. Thanks for Attention

More Related Content