Skip to main content

Posts

Showing posts with the label Java OOPs

Java Object Oriented Programming (OOPs)

Java OOPs Java Object Oriented Programming (OOPs) One prime characteristic that is constant in the world of software is the change and advancement in software. That change is one of the most critical aspects of software development. Development of new tools and techniques is common for everyday technology users. For software engineers, the most important thing is the maintainability, portability, reusability, integrity, security, and user-friendliness. So to build today’s complex software it is just not enough to put together a sequence of programming statements or procedures. Programmers need to use sound construction techniques and program structures that are easy to figure out implement and modify in a wide variety of situations. This is possible and efficient to use with  Object-oriented Programming  techniques. Since the inventions of the computer and programming languages, many approaches have been tried. These includes: Modular Programming Top-down Programming Structure...

Java Object and Classes

Java Object and Classes This lesson mainly focused on Java object and class and describes the features of Java object-oriented programming . Java has following OOPS features: Encapsulation Inheritance Polymorphism Abstraction Classes Objects Instance Method Message Parsing In this lesson our major focus on  Objects and Classes . What is Object? In real-world an entity that has state and its behavior is known as an object. For Example: A Car is an object. It has states (name, color, model) and its behavior (changing gear, applying brakes). A Pen is an object. Its name is Parker, color is silver etc. known as its state. It is used to write, so writing is its behavior. In real-world object and software object have conceptually similar characteristics. In terms of object-oriented programming, software objects also have a state and behavior. What is a class? A class is a template or blueprint that is used to create objects. Class representation of objects and the sets of ...

Java Constructor

Java Constructor As you all know that all objects that are created must be given initial values which can be done in two ways. The first way of doing this is to use the dot operator to access the instance variable and then assigning values to them individually. This can be a tedious approach to initialize all the variables of the object in this manner. The second approach takes the help of method like getData() or init() etc, to initialize each object individually using statements like: val1 . getdata ( 12 , 25 ); Here, in this chapter, you will be dealing with constructors of Java, and learn about how they are used within a Java program and how they are useful Object Oriented Programming concept. What are Constructors? Constructors are special member functions whose task is to initialize the objects of its class. It is treated as a special member function because its name is the same as the class name. Java constructors are invoked when their objects are created. It is named such beca...

Java static and this Keyword

Java static and this Keyword There are various reserve words that Java provides to do different types of operations. Keywords are reserved words whose meanings are already known to Java compiler. There are two important keywords in Java that are used for very special purposes. In this chapter we will learn about the two special types of keywords: static this What is static in Java? Static is a keyword that acts as a non-access modifier in Java that is used mainly to manage memory. The variable or Method that are marked static belongs to the Class rather than to any particular instance. A Static method cannot access an instance variable. If a Class contains any static blocks then that block will be executed only when the Class is loaded in JVM. Programmers can apply the Java keyword static with different programming objects like: variables methods initialization – block nested class Static keyword is unacceptable to the following Class Constructor Local inner classes Inner class methods...

Java super and final keyword

Java super and final keyword super  and  final  keywords are two popular and effective keywords in Java. They also play a major role in dealing with Java programs and their classes. In this chapter, you will learn about how to use super and final within a Java program. What is super in Java? Super is a keyword of Java which refers to the immediate parent of a class and is used inside the subclass method definition for calling a method defined in the super class. A superclass having methods as private cannot be called. Only the methods which are public and protected can be called by the keyword super. It is also used by class constructors to invoke constructors of its parent class. Syntax: super .< method - name >(); Usage of superclass Super variables refer to the variable of a variable of the parent class. Super() invokes the constructor of immediate parent class. Super refers to the method of the parent class. Here is an example of Java program which uses the supe...

For Programs Click Here