CS PROGRAMMING PARADIGMS Regulation Lecture Notes Anna University CS PROGRAMMING PARADIGMS Lecture notes PP Notes 5TH. Anna University Fifth semester Third Year lecture Notes for Programming Paradigms CS PP free pdf! The Third Year,Fifth semester Anna. 5th semester Notes. GKM College Notes: 1. Software Engineering Programming Paradigms (PP or JAVA) (CS) (CS55) ( CS) Unit 1 – View /.
|Published (Last):||14 September 2005|
|PDF File Size:||19.12 Mb|
|ePub File Size:||11.3 Mb|
|Price:||Free* [*Free Regsitration Required]|
OOP is defined as object oriented programming. A class is defined by the user is data type with the template that helps in defining the properties. Once the class type has been defined we can create the variables of that type using declarations that are similar to the basic type declarations. In java instances of the classes which are actual objects Eg: These variables are called as instance variables. Methods are declared inside the class immediate after the instance variables declaration.
An object in java essentially a block of memory, which contains space to store all the instance variables.
CS Programming Paradigms Lecture Notes – All Units – SEC Edition
Creating an object is also referred as instantiating an object. Object in java are created using the new operator. Methods are similar to functions or procedures that are available in other programming languages. Inheritance is the process of forming a new class from an existing class or base class. The base class is also known as parent class or super class, the new class that is formed is called derived class.
Paradogms class is also known as a child class or fs2305 class. Inheritance helps in reducing the overall code size reusability of the program, which is an important concept in object-oriented programming.
Data abstraction increases the power of programming language by creating user defined data types. Data abstraction also represents the needed information in the program without presenting the details. Data encapsulation combines data and functions into nptes single unit called class. When using Data Encapsulation, data is not accessed directly; it is only accessible through the functions present inside the class.
CS2305 Programming Paradigms Question Bank – 16 Mark Questions – Anna University CSE 5th Semester
Data encapsulation enables the important concept of data hiding possible. Polymorphism allows routines to use variables of different types at notds times. An operator or function can be given different meanings or functions. The ability of objects to respond differently nores the same message or function call.
A message passing system provides primitives for sending and receiving messages using objects. These primitives may by either synchronous or asynchronous or both.
Explain Constructors with examples. Constructors are the method.
Lecture notes: Programming Paradigms
It is used to give initial values to instance variables of the objects. It is automatically called at the time of object creation. A constructor has the same name as the class. Lechure class programming have more than one constructor.
A constructor can take zero ,one ,or more parameters. A constructor has no return value. A constructor is always called with the new operator. Explain Packages in detail. Packages are container for the classes. It is stored in a hierarichical manner. If we want to use the packages in a class, we want to import it. The two types of packages are: Packages reduce the complexity of the software because a large number of classes can be grouped into a limited number of packages.
We can create classes with same name in different packages. Using packages we can hide classes. We may like to use many of cz2305 classes Import packagename. Access a package The import statement can be used to search a list of packages for note particular class.
The general form of import statement for searching class is a as follows. How to declare array?
Discuss the methods under Array Class. Arrays An array is a data structure that stores a collection of values of the same type. You access each paraadigms value through an integer index. Array Name [index] Integer constant, variable, or expression For Instance we can define an array name salary to represent a set of salaries of a group of employees. A particular value is indicated by writing a number called index in brackets after the array name. Types of arrays One dimensional arrays Two dimensional arrays One Dimensional arrays A list of items can be given one variable name using only one subscript and such a variable is called single- subscripted of one dimensional array.
Lefture subscript can also start from 0. This process is known as initialization using the array subscripts as shown below. We can obtain the length of array a using a. Series of characters represents a string, and easiest way to represent the string is array Eg: Explain the comments for classes, methods, fields and link. The Javadoc is written next to the items without any separating newline. The class declaration usually contains: This is followed by 2 a longer description that may span in multiple paragraphs.
In those the details can be explained in full. This section, marked in brackets , is optional.
If there were any, it would be here. Here the variable contains only the short description: Class, Interface version version Provides version entry. Max one per Class, Interface Class or Interface. Field, Method Provides a link to other element of Class, Interface, documentation. Field, Method Describes a method parameter. Method return description Describes the return value. Method exception classname description Describes an exception that may be throws classname thrown from this method.
Static Methods The mean method would work just as well if it wasn’t declared static, as long as it was called from within the same class. If called from outside the class and it wasn’t declared static, it would have to be qualified uselessly with an object.
Even when used within the class, there are good reasons to define a method as static when it could be. Anyone seeing that a method is static will know how to call it.
Similarly, any programmer looking at the code will know that a static method can’t interact with instance variables, which makes reading and debugging easier. A compiler will usually produce slightly more efficient code because no implicit object parameter has to be passed to the meth Calling static methods There are two cases. Called from within the same class Just write the static method name.
For instance methods, this is the object that the prpgramming will access. For static methods, the class name should be specified. Static Members Let us assume that we want lfcture define a member that is common to all the objects and can be accessed without using a particular object. That is the member belongs to the class as a whole rather than the objects created from the class.
It can be defined as follows staticint count; Static int max paraxigms x, int y ; The members declared as fs2305 are known as static members. Static variable are used when we want to have a variable common to all instances of class. Using static members Final methods and variables All method and variables can be overridden by default subclasses.
If we wish to prevent the subclasses from overriding the members of the superclass, we can declare them as final using the keyword final as a modifier.
Finalizer methods In java we know that Garbage collector will automatically free the memory resources used by objects. But objects may hold othernon-object resources such as file descriptor or window system fonts.
The Garbage collector cannot free those resources. The finalizer method is simply finalize and can be added to any class. Finalize method should explicitly specify the operation to be performed 7. Explain method overriding with example program. A method is said to be overridden when one is in parent class and another is in child class with the same name, same return type, same parameter. Explain the concept of inheritance and its types. Inheritance The concept of inheritance is used to make the things from general to more specific e.
When we hear the word vehicle then we got an image in our mind that it moves from one place to another place it is used for traveling or carrying goods but the word vehicle does not specify whether it is two or three or four wheeler because it is a general word. Nltes the word car makes a more specific image in mind than vehicle, that the car has oecture wheels.
It concludes from the example that car is a note word and vehicle is the general word. If we think technically to this example then vehicle is the super class or base class or parent class and car is the subclass or child progrmming because every car has the features of it’s parent in this case vehicle class The following kinds of inheritance are there in java. Simple Sc2305 Multilevel Inheritance Simple Inheritance When a subclass is derived simply pecture it’s parent class then this mechanism is known as simple inheritance.
In case of simple inheritance there is only a sub class and it’s parent class.