When you want to succeed as bad as you want to breathe, then you’ll be successful.
--Your friends at LectureNotes

Note for Java Programming - JAVA by Rama Khandavilli

  • Java Programming - JAVA
  • Note
  • Biju Patnaik University of Technology Rourkela Odisha - BPUT
  • Computer Science Engineering
  • B.Tech
  • 5 Topics
  • 204 Offline Downloads
  • Uploaded 2 years ago
0 User(s)
Download PDFOrder Printed Copy

Share it with your friends

Leave your Comments

Text from page-2

1-UNIT Need for oop paradigm • The object oriented paradigm is a methodology for producing reusable software components • The object-oriented paradigm is a programming methodology that promotes the efficient design and development of software systems using reusable components that can be quickly and safely assembled into larger systems. • Object oriented programming has taken a completely different direction and will place an emphasis on object s and information. With object oriented programming, a problem will be broken down into a number of units .these are called objects .The foundation of oop is the fact that it will place an emphasis on objects and classes. There are number of advantages to be found with using the oop paradigm, and some of these are oop paradigm • Object oriented programming is a concept that was created because of the need to overcome the problems that were found with using structured programming techniques. While structured programming uses an approach which is top down, oop uses an approach which is bottom up. • A paradigm is a way in which a computer language looks at the problem to be solved. We divide computer languages into four paradigms: procedural, object-oriented, functional and declarative • A paradigm shift from a function-centric approach to an object-centric approach to software development • A program in a procedural paradigm is an active agent that uses passive objects that we refer to as data or data items. • The basic unit of code is the class which is a template for creating run-time objects. • Classes can be composed from other classes. For example, Clocks can be constructed as an aggregate of Counters. • The object-oriented paradigm deals with active objects instead of passive objects. We encounter many active objects in our daily life: a vehicle, an automatic door, a dishwasher and so on. The actions to be performed on these objects are included in the object: the objects need only to receive the appropriate stimulus from outside to perform one of the actions. • A file in an object-oriented paradigm can be packed with all the procedures—called methods in the object-oriented paradigm—to be performed by the file: printing, copying, SVECW IT DEPT Page 2

Text from page-3

deleting and so on. The program in this paradigm just sends the corresponding request to the object • Java provides automatic garbage collection, relieving the programmer of the need to ensure that unreferenced memory is regularly deallocated.need Object Oriented Paradigm – Key Features • Encapsulation • Abstraction • Inheritance • Polymorphis A Way of viewing World- Agents • The word agent has found its way into a number of technologies. It has been applied to aspects of artificial intelligence research and to constructs developed for improving the experience provided by collaborative online social environments (MUDS, MOOs, and the like). It is a branch on the tree of distributed computing. There are agent development toolkits and agent programming languages. • The Agent Identity class defines agent identity. An instance of this class uniquely identifies an agent. Agents use this information to identify the agents with whom they are interested in collaborating. • The Agent Host class defines the agent host. An instance of this class keeps track of every agent executing in the system. It works with other hosts in order to transfer agents. • The Agent class defines the agent. An instance of this class exists for each agent executing on a given agent host. • OOP uses an approach of treating a real world agent as an object. • Object-oriented programming organizes a program around its data (that is, objects) and a set of well-defined interfaces to that data. • An object-oriented program can be characterized as data controlling access to code by switching the controlling entity to data. Responsibility • In object-oriented design, the chain-of-responsibility pattern is a design pattern consisting of • a source of command objects and a series of processing objects.. Each processing object contains logic that defines the types of command objects that it can handle; the rest are passed to the next processing object in the chain. A mechanism also exists for adding new processing objects to the end of this chain. SVECW IT DEPT Page 3

Text from page-4

• • • • • Primary motivation is the need for a platform-independent (that is, architecture- neutral) language that could be used to create software to be embedded in various consumer electronic devices, such as microwave ovens and remote controls. Objects with clear responsibilities Each class should have a clear responsibility. If you can't state the purpose of a class in a single, clear sentence, then perhaps your class structure needs some thought. In object-oriented programming, the single responsibility principle states that every class should have a single responsibility, and that responsibility should be entirely encapsulated by the class. All its services should be narrowly aligned with that responsibility. Messages • • • • • • Message implements the Part interface. Message contains a set of attributes and a "content". Message objects are obtained either from a Folder or by constructing a new Message object of the appropriate subclass. Messages that have been received are normally retrieved from a folder named "INBOX". A Message object obtained from a folder is just a lightweight reference to the actual message. The Message is 'lazily' filled up (on demand) when each item is requested from the message. Note that certain folder implementations may return Message objects that are pre-filled with certain user-specified items. To send a message, an appropriate subclass of Message (e.g., Mime Message) is instantiated, the attributes and content are filled in, and the message is sent using the Transport. Send method. We all like to use programs that let us know what's going on. Programs that keep us informed often do so by displaying status and error messages. These messages need to be translated so they can be understood by end users around the world. • The Section discusses translatable text messages. Usually, you're done after you move a message String into a Resource Bundle. • If you've embedded variable data in a message, you'll have to take some extra steps to prepare it for translation. Methods • • • • The only required elements of a method declaration are the method's return type, name, a pair of parentheses, (), and a body between braces, {}. Two of the components of a method declaration comprise the method signature—the method's name and the parameter types. More generally, method declarations have six components, in order: Modifiers—such as public, private, and others you will learn about later. SVECW IT DEPT Page 4

Text from page-5

• The return type—the data type of the value returned by the method, or void if the method does not return a value. • The method name—the rules for field names apply to method names as well, but the convention is a little different. • The parameter list in parenthesis—a comma-delimited list of input parameters, preceded by their data types, enclosed by parentheses, (). If there are no parameters, you must use empty parentheses. • The method body, enclosed between braces—the method's code, including the declaration of local variables, goes here. Naming a Method Although a method name can be any legal identifier, code conventions restrict method names. By convention, method names should be a verb in lowercase or a multi-word name that begins with a verb in lowercase, followed by adjectives, nouns, etc. In multiword names, the first letter of each of the second and following words should be capitalized. Here are some examples: run run Fast getBackground getFinalData compareTo setX isEmpty Typically, a method has a unique name within its class. However, a method might have the same name as other methods due to method overloading. • Overloading Methods The Java programming language supports overloading methods, and Java can distinguish between methods with different method signatures. This means that methods within a class can have the same name if they have different parameter lists (there are some qualifications to this that will be discussed in the lesson titled "Interfaces and Inheritance"). SVECW IT DEPT Page 5

Lecture Notes