The document discusses various object-oriented programming concepts in Java including classes, objects, constructors, method overloading, passing arguments, returning objects, recursion, the 'new' operator, 'this' and 'static' keywords, and inner classes. It provides examples to illustrate class and object declarations, creating objects using the new operator, using constructors, overloading methods and constructors, passing arguments by value and reference, returning objects from methods, using recursion to calculate factorials, and using the this and static keywords.
This document discusses inheritance in C++. It defines inheritance as a mechanism that allows classes to acquire properties from other classes. The class that inherits properties is called the derived or child class, while the class being inherited from is called the base or parent class. The key advantages of inheritance are that it saves memory, time, and development efforts by promoting code reuse. The document provides examples of single inheritance with one parent and one child class, and multiple inheritance with a class inheriting from multiple parent classes.
The wrapper classes in Java are used to convert primitive data types like int and float into objects. There are eight wrapper classes that correspond to the eight primitive types. Wrapper classes allow primitive types to be used in contexts that require objects, like collections. They provide methods to convert between primitive types and their corresponding wrapper class objects.
This document discusses inheritance in object-oriented programming. It defines inheritance as allowing code reuse through classes inheriting traits from parent classes. The document covers different types of inheritance like single, multi-level, multiple and hierarchical inheritance. It also discusses inheritance in various programming languages like C++, Java, Python and ADA. The advantages of inheritance are code reuse and extending parent classes without modifying them, while disadvantages include subclasses being brittle and inheritance relationships not changing at runtime.
1) A constructor in Java is a special method that is used to initialize objects and is called when an object is created. It can set initial values for object attributes.
2) There are different types of constructors including default, parameterized, and copy constructors. The default constructor takes no parameters, parameterized constructors take parameters to initialize objects with different values, and copy constructors are used to create a copy of an object.
3) Constructor overloading allows a class to have multiple constructors with the same name but different parameters, allowing objects to be initialized in different ways.
The document discusses key concepts in Java including classes, objects, methods, and command line arguments. A class defines common properties and behaviors for objects through fields and methods. Objects are instantiated from classes and can access fields and methods using dot notation. Command line arguments allow passing data into a Java application and are accessed through the args parameter in the main method.
Constructor is a special member method which will be called automatically when you create an object of any class.
The main purpose of using constructor is to initialize an object.
http://www.tutorial4us.com/java/java-constructor
Java abstract class & abstract methods,Abstract class in java
Abstract classes are classes that contain one or more abstract methods. An abstract method is a method that is declared, but contains no implementation. Abstract classes may not be instantiated, and require subclasses to provide implementations for the abstract methods.
Chapter 02: Classes Objects and Methods Java by Tushar B KuteTushar B Kute
The lecture was condcuted by Tushar B Kute at YCMOU, Nashik through VLC orgnanized by MSBTE. The contents can be found in book "Core Java Programming - A Practical Approach' by Laxmi Publications.
This document discusses inheritance in C++. It defines inheritance as a mechanism that allows classes to acquire properties from other classes. The class that inherits properties is called the derived or child class, while the class being inherited from is called the base or parent class. The key advantages of inheritance are that it saves memory, time, and development efforts by promoting code reuse. The document provides examples of single inheritance with one parent and one child class, and multiple inheritance with a class inheriting from multiple parent classes.
The wrapper classes in Java are used to convert primitive data types like int and float into objects. There are eight wrapper classes that correspond to the eight primitive types. Wrapper classes allow primitive types to be used in contexts that require objects, like collections. They provide methods to convert between primitive types and their corresponding wrapper class objects.
This document discusses inheritance in object-oriented programming. It defines inheritance as allowing code reuse through classes inheriting traits from parent classes. The document covers different types of inheritance like single, multi-level, multiple and hierarchical inheritance. It also discusses inheritance in various programming languages like C++, Java, Python and ADA. The advantages of inheritance are code reuse and extending parent classes without modifying them, while disadvantages include subclasses being brittle and inheritance relationships not changing at runtime.
1) A constructor in Java is a special method that is used to initialize objects and is called when an object is created. It can set initial values for object attributes.
2) There are different types of constructors including default, parameterized, and copy constructors. The default constructor takes no parameters, parameterized constructors take parameters to initialize objects with different values, and copy constructors are used to create a copy of an object.
3) Constructor overloading allows a class to have multiple constructors with the same name but different parameters, allowing objects to be initialized in different ways.
The document discusses key concepts in Java including classes, objects, methods, and command line arguments. A class defines common properties and behaviors for objects through fields and methods. Objects are instantiated from classes and can access fields and methods using dot notation. Command line arguments allow passing data into a Java application and are accessed through the args parameter in the main method.
Constructor is a special member method which will be called automatically when you create an object of any class.
The main purpose of using constructor is to initialize an object.
http://www.tutorial4us.com/java/java-constructor
Java abstract class & abstract methods,Abstract class in java
Abstract classes are classes that contain one or more abstract methods. An abstract method is a method that is declared, but contains no implementation. Abstract classes may not be instantiated, and require subclasses to provide implementations for the abstract methods.
Chapter 02: Classes Objects and Methods Java by Tushar B KuteTushar B Kute
The lecture was condcuted by Tushar B Kute at YCMOU, Nashik through VLC orgnanized by MSBTE. The contents can be found in book "Core Java Programming - A Practical Approach' by Laxmi Publications.
The document discusses key concepts in object-oriented programming including objects, classes, messages, and requirements for object-oriented languages. An object is a bundle of related variables and methods that can model real-world things. A class defines common variables and methods for objects of a certain kind. Objects communicate by sending messages to each other specifying a method name and parameters. For a language to be object-oriented, it must support encapsulation, inheritance, and dynamic binding.
Selection Statements
Using if and if...else
Nested if Statements
Using switch Statements
Conditional Operator
Repetition Statements
Looping: while, do, and for
Nested loops
Using break and continue
This document discusses inheritance in object-oriented programming. It defines inheritance as establishing a link between classes that allows sharing and accessing properties. There are three types of inheritance: single, multilevel, and hierarchical. Single inheritance involves one parent and one child class, multilevel inheritance adds intermediate classes, and hierarchical inheritance has one parent and multiple child classes. The document provides examples of inheritance code in Java and demonstrates a program using inheritance with interfaces. It notes some limitations of inheritance in Java.
There are three types of variables in Java: local, instance, and class/static variables. Local variables are declared within methods and can only be accessed within that method. Instance variables are declared within a class but outside of methods, and can be accessed by any non-static method of that class. Class/static variables are also declared within a class but with the static keyword, and can be accessed from both static and non-static contexts.
The document discusses the structure of a Java program. A Java program contains classes, with one class containing a main method that acts as the starting point. Classes contain data members and methods that operate on the data. Methods contain declarations and executable statements. The structure also includes sections for documentation, package statements, import statements, interface statements, and class definitions, with the main method class being essential.
This document discusses templates in C++. Templates allow functions and classes to work with multiple data types without writing separate code for each type. There are two types of templates: class templates, which define a family of classes that operate on different data types, and function templates, which define a family of functions that can accept different data types as arguments. Examples of each template type are provided to demonstrate how they can be used to create reusable and flexible code.
- Java inner classes are classes declared within other classes or interfaces. They allow grouping of logically related classes and interfaces and can access all members of the outer class, including private ones.
- There are three main advantages of inner classes: they can access private members of the outer class, they make code more readable by grouping related classes, and they require less code.
- The two types of inner classes are non-static (inner) classes and static nested classes. Non-static classes can access outer class members like private variables while static classes cannot access non-static members only static ones.
- Examples demonstrate member inner classes, anonymous inner classes, local inner classes, and static nested classes in Java and how they can
The document summarizes a presentation on exception handling given by the group "Bug Free". It defines what exceptions are, why they occur, and the exception hierarchy. It describes checked and unchecked exceptions, and exception handling terms like try, catch, throw, and finally. It provides examples of using try-catch blocks, multiple catch statements, nested try-catch, and throwing and handling exceptions.
This document discusses inheritance in Java programming. It defines inheritance as a mechanism where a subclass acquires the properties and behaviors of a superclass. It describes the key types of inheritance in Java including single, multilevel, and hierarchical inheritance. It also outlines some advantages, such as code reusability and reliability, and disadvantages, such as increased coupling between classes.
Type casting involves assigning a value of one data type to a variable of another type. There are two types of casting: widening (implicit) and narrowing (explicit). Widening casting converts data to a broader type without needing explicit casting, like converting an int to a long. Narrowing casting converts to a narrower data type and requires explicit casting, such as converting a double to a long.
Our trainer’s having vast experience in real time environment. If anyone has a dream for their career in software programming, then go for java because it is a popular route to establish and fulfill your dreams.
We offer the best quality and affordable training, so you get trained from where you are, from our experienced instructors, remotely using Webex / Gotomeeting.
In this you learn about
Access Modifiers in Java / Visibility Modifiers in Java
1. Default access modifier
2. private access modifier
3. protected access modifier
4. public access modifier
An interface in Java is a blueprint of a class that defines static constants and abstract methods. Interfaces are implemented by classes where they inherit the properties and must define the body of the abstract methods. Key points are:
- Interfaces can only contain abstract methods and static constants, not method bodies.
- Classes implement interfaces to inherit the properties and must define the abstract method bodies.
- An interface can extend other interfaces and a class can implement multiple interfaces.
The document discusses Java wrapper classes. Wrapper classes wrap primitive data types like int, double, boolean in objects. This allows primitive types to be used like objects. The main wrapper classes are Byte, Short, Integer, Long, Character, Boolean, Double, Float. They provide methods to convert between primitive types and their wrapper objects. Constructors take primitive values or strings to create wrapper objects. Methods like parseInt() convert strings to primitive types.
This document provides an overview of basic object-oriented programming (OOP) concepts including objects, classes, inheritance, polymorphism, encapsulation, and data abstraction. It defines objects as entities with both data (characteristics) and behavior (operations). Classes are blueprints that are used to create objects. Inheritance allows objects to inherit properties from parent classes. Polymorphism allows code to take different forms. Encapsulation wraps data and functions into classes, hiding information. Data abstraction focuses on important descriptions without details.
Modules allow grouping of related functions and code into reusable files. Packages are groups of modules that provide related functionality. There are several ways to import modules and their contents using import and from statements. The document provides examples of creating modules and packages in Python and importing from them.
The Java Collections Framework provides classes and interfaces that help store and manipulate collections of objects. The main collection interfaces are List, Set, and Map. Lists allow duplicate elements and access by index. Common List implementations are ArrayList and LinkedList. Sets do not allow duplicates. Common Set implementations are HashSet, LinkedHashSet, and TreeSet. Maps store objects in key-value pairs and cannot have duplicate keys. Common Map implementations are HashMap, TreeMap, and LinkedHashMap.
The document discusses method overloading and overriding in Java. It defines method overloading as having multiple methods with the same name but different parameters, while overriding involves subclasses providing specific implementations of methods in the parent class. It provides examples of overloading methods by changing parameters and data types, and explains why overriding is not possible by only changing the return type due to ambiguity. The use of the super keyword to refer to parent class members is also explained.
The document discusses different types of nested classes in Java - member inner classes, anonymous inner classes, and local inner classes. It provides examples of each type of nested class and how they can access members of the outer class. Method overloading is also covered, explaining how methods can be overloaded by changing parameters and return types. The key differences between passing objects and primitives by value and reference are explained.
A class defines the blueprint for objects of a certain type. It contains variables to hold an object's state and methods to perform its behaviors. Constructors initialize new objects, while methods allow objects to interact. Objects are passed into methods by value for primitive types and by reference for class types. Classes use access modifiers like public and private to control variable and method visibility. Garbage collection automatically frees memory for unused objects. Method overloading and recursion allow methods to be reused in different contexts.
The document discusses key concepts in object-oriented programming including objects, classes, messages, and requirements for object-oriented languages. An object is a bundle of related variables and methods that can model real-world things. A class defines common variables and methods for objects of a certain kind. Objects communicate by sending messages to each other specifying a method name and parameters. For a language to be object-oriented, it must support encapsulation, inheritance, and dynamic binding.
Selection Statements
Using if and if...else
Nested if Statements
Using switch Statements
Conditional Operator
Repetition Statements
Looping: while, do, and for
Nested loops
Using break and continue
This document discusses inheritance in object-oriented programming. It defines inheritance as establishing a link between classes that allows sharing and accessing properties. There are three types of inheritance: single, multilevel, and hierarchical. Single inheritance involves one parent and one child class, multilevel inheritance adds intermediate classes, and hierarchical inheritance has one parent and multiple child classes. The document provides examples of inheritance code in Java and demonstrates a program using inheritance with interfaces. It notes some limitations of inheritance in Java.
There are three types of variables in Java: local, instance, and class/static variables. Local variables are declared within methods and can only be accessed within that method. Instance variables are declared within a class but outside of methods, and can be accessed by any non-static method of that class. Class/static variables are also declared within a class but with the static keyword, and can be accessed from both static and non-static contexts.
The document discusses the structure of a Java program. A Java program contains classes, with one class containing a main method that acts as the starting point. Classes contain data members and methods that operate on the data. Methods contain declarations and executable statements. The structure also includes sections for documentation, package statements, import statements, interface statements, and class definitions, with the main method class being essential.
This document discusses templates in C++. Templates allow functions and classes to work with multiple data types without writing separate code for each type. There are two types of templates: class templates, which define a family of classes that operate on different data types, and function templates, which define a family of functions that can accept different data types as arguments. Examples of each template type are provided to demonstrate how they can be used to create reusable and flexible code.
- Java inner classes are classes declared within other classes or interfaces. They allow grouping of logically related classes and interfaces and can access all members of the outer class, including private ones.
- There are three main advantages of inner classes: they can access private members of the outer class, they make code more readable by grouping related classes, and they require less code.
- The two types of inner classes are non-static (inner) classes and static nested classes. Non-static classes can access outer class members like private variables while static classes cannot access non-static members only static ones.
- Examples demonstrate member inner classes, anonymous inner classes, local inner classes, and static nested classes in Java and how they can
The document summarizes a presentation on exception handling given by the group "Bug Free". It defines what exceptions are, why they occur, and the exception hierarchy. It describes checked and unchecked exceptions, and exception handling terms like try, catch, throw, and finally. It provides examples of using try-catch blocks, multiple catch statements, nested try-catch, and throwing and handling exceptions.
This document discusses inheritance in Java programming. It defines inheritance as a mechanism where a subclass acquires the properties and behaviors of a superclass. It describes the key types of inheritance in Java including single, multilevel, and hierarchical inheritance. It also outlines some advantages, such as code reusability and reliability, and disadvantages, such as increased coupling between classes.
Type casting involves assigning a value of one data type to a variable of another type. There are two types of casting: widening (implicit) and narrowing (explicit). Widening casting converts data to a broader type without needing explicit casting, like converting an int to a long. Narrowing casting converts to a narrower data type and requires explicit casting, such as converting a double to a long.
Our trainer’s having vast experience in real time environment. If anyone has a dream for their career in software programming, then go for java because it is a popular route to establish and fulfill your dreams.
We offer the best quality and affordable training, so you get trained from where you are, from our experienced instructors, remotely using Webex / Gotomeeting.
In this you learn about
Access Modifiers in Java / Visibility Modifiers in Java
1. Default access modifier
2. private access modifier
3. protected access modifier
4. public access modifier
An interface in Java is a blueprint of a class that defines static constants and abstract methods. Interfaces are implemented by classes where they inherit the properties and must define the body of the abstract methods. Key points are:
- Interfaces can only contain abstract methods and static constants, not method bodies.
- Classes implement interfaces to inherit the properties and must define the abstract method bodies.
- An interface can extend other interfaces and a class can implement multiple interfaces.
The document discusses Java wrapper classes. Wrapper classes wrap primitive data types like int, double, boolean in objects. This allows primitive types to be used like objects. The main wrapper classes are Byte, Short, Integer, Long, Character, Boolean, Double, Float. They provide methods to convert between primitive types and their wrapper objects. Constructors take primitive values or strings to create wrapper objects. Methods like parseInt() convert strings to primitive types.
This document provides an overview of basic object-oriented programming (OOP) concepts including objects, classes, inheritance, polymorphism, encapsulation, and data abstraction. It defines objects as entities with both data (characteristics) and behavior (operations). Classes are blueprints that are used to create objects. Inheritance allows objects to inherit properties from parent classes. Polymorphism allows code to take different forms. Encapsulation wraps data and functions into classes, hiding information. Data abstraction focuses on important descriptions without details.
Modules allow grouping of related functions and code into reusable files. Packages are groups of modules that provide related functionality. There are several ways to import modules and their contents using import and from statements. The document provides examples of creating modules and packages in Python and importing from them.
The Java Collections Framework provides classes and interfaces that help store and manipulate collections of objects. The main collection interfaces are List, Set, and Map. Lists allow duplicate elements and access by index. Common List implementations are ArrayList and LinkedList. Sets do not allow duplicates. Common Set implementations are HashSet, LinkedHashSet, and TreeSet. Maps store objects in key-value pairs and cannot have duplicate keys. Common Map implementations are HashMap, TreeMap, and LinkedHashMap.
The document discusses method overloading and overriding in Java. It defines method overloading as having multiple methods with the same name but different parameters, while overriding involves subclasses providing specific implementations of methods in the parent class. It provides examples of overloading methods by changing parameters and data types, and explains why overriding is not possible by only changing the return type due to ambiguity. The use of the super keyword to refer to parent class members is also explained.
The document discusses different types of nested classes in Java - member inner classes, anonymous inner classes, and local inner classes. It provides examples of each type of nested class and how they can access members of the outer class. Method overloading is also covered, explaining how methods can be overloaded by changing parameters and return types. The key differences between passing objects and primitives by value and reference are explained.
A class defines the blueprint for objects of a certain type. It contains variables to hold an object's state and methods to perform its behaviors. Constructors initialize new objects, while methods allow objects to interact. Objects are passed into methods by value for primitive types and by reference for class types. Classes use access modifiers like public and private to control variable and method visibility. Garbage collection automatically frees memory for unused objects. Method overloading and recursion allow methods to be reused in different contexts.
This document provides an overview of object-oriented programming concepts in Java, including classes, objects, variables, methods, constructors, abstraction, encapsulation, inheritance, and polymorphism. It defines classes and objects, and describes how classes act as blueprints for objects. It explains the syntax for defining classes and class members like variables and methods. It also covers method overloading, different types of methods, and how constructors are used to initialize objects. The document concludes with brief explanations of abstraction, encapsulation, inheritance, and polymorphism as fundamental principles of object-oriented design.
MODULE_3_Methods and Classes Overloading.pptxVeerannaKotagi1
The document discusses method overloading, constructor overloading, passing objects as parameters to methods, and recursion in Java. Some key points:
- Method overloading allows multiple methods with the same name but different parameters within a class. Java uses parameters to determine which overloaded method to call.
- Constructors can also be overloaded based on parameters. A Box class example demonstrates calling the proper overloaded constructor.
- Objects can be passed as parameters to methods. Changes to the object within the method will affect the original object passed in.
- Primitive types are passed by value while objects are passed by reference.
Class is a blueprint for creating object instances that share common attributes and behaviors. It defines the variables and methods that are common to all objects of that class. When an object is created from a class, it is said to be an instance of that class. Objects contain state in the form of attributes and behavior in the form of methods. Classes in Java can define access levels for variables and methods as public, private, protected, or without a specified level (default).
This document discusses object-oriented programming concepts in Objective-C such as classes, inheritance, polymorphism, and exceptions. It covers creating interface and implementation files, using properties and methods, inheritance hierarchies with subclasses, overriding methods, abstract classes, polymorphism through dynamic binding, and exceptions. Key topics include creating .h and .m files to define a class, using self to reference the current object, returning objects from methods, and extending classes through inheritance while allowing method overriding.
This document discusses object-oriented programming concepts in Java including:
- Classes define templates for objects with similar attributes and behaviors.
- Objects are instances of classes that represent real-world entities. They have attributes like properties and behaviors like methods.
- Methods operate on instances of classes. Constructors initialize objects upon creation.
- Overloading allows multiple methods or constructors with the same name but different parameters.
- Objects can be passed as parameters and returned from methods. Arrays can hold multiple object references.
- Ruby is an object-oriented language where everything is an object and classes define methods that objects respond to.
- Classes can inherit and override methods from superclasses and include methods from modules.
- The initialize method is used as a constructor to initialize instance variables. Accessors provide access to instance variables.
- Common methods like +, -, *, [] can be defined for a class to allow arithmetic and array-like access to objects.
To learn about the basic concepts of Object Oriented Programming and Inheritance plus different Inheritance Models and interview questions will be covered.
The document discusses inheritance in C++. It defines inheritance as a mechanism where one class acquires properties of another class. Key points include:
(1) Inheritance allows classes to form hierarchies with more general classes at higher levels and more specific subclasses below.
(2) Derived classes inherit data and operations from base classes, allowing code reuse and extension of existing classes.
(3) Virtual functions allow dynamic binding so the correct overloaded function is called based on the object's actual type at runtime rather than its declared type.
The document discusses key concepts of classes and objects in C# including defining classes, adding variables and methods, member access modifiers, creating objects, constructors, static members, private constructors, and indexers. It defines classes as user defined data types that can encapsulate data as fields and functions as methods. Objects are instances of classes that allow data and methods to be accessed. Constructors initialize objects, while static members are associated with the class rather than individual objects.
Java As an OOP Language,Exception Handling & AppletsHelen SagayaRaj
Java classes can define instance variables, class variables, methods, and constructors. Instance variables are declared within a class but outside methods and are unique to each object. Class variables are declared with the static keyword and are shared among all objects of a class. Constructors initialize new objects and have the same name as the class without a return type. Inheritance allows a subclass to extend a superclass, overriding methods and using the super constructor. Finalizer methods cleanup objects before garbage collection.
The document discusses various topics in Objective-C including variables, data types, categories, protocols, and composite objects. It provides code examples to illustrate initializing objects, variable scope, enumerated data types, typedefs, data type conversion, categories, class extensions, protocols, delegates, and composite objects in Objective-C and compares some of these concepts to Java.
UNIT-2.pptx CS3391 Inheritance , types, packages and InterfacesSakkaravarthiS1
This document discusses various Java concepts including method overloading, objects as parameters, returning objects, static, nested and inner classes, inheritance basics and types, the super keyword, method overriding and dynamic method dispatch, abstract classes, final with inheritance, packages and interfaces. It provides examples and explanations of each concept.
Class is a blueprint for creating objects that share common attributes and behaviors. A class defines the data and methods that describe the object. Classes in Java can contain data members, methods, constructors, nested classes, and interfaces. Objects are instances of classes that occupy memory at runtime and can access class members like variables and methods. Constructors initialize an object when it is created and have the same name as the class. The this keyword refers to the current object in a method or constructor. Command line arguments can be passed to a program as strings and accessed via the args parameter in the main method.
1. A class is a blueprint for objects that defines common properties and methods. It can include modifiers, name, superclass/interfaces, and a class body.
2. An object is created using the new keyword, assigning the object to a reference variable. Reference variables store an object's address in memory. Assigning one reference variable to another does not create distinct copies but points to the same object.
3. A method performs a specific task and can return a result. It includes modifiers, return type, name, parameters, and a method body. Method overloading allows methods with the same name but different parameters.
Similar to Classes, Objects and Method - Object Oriented Programming with Java (20)
General packet radio services (GPRS) is step to efficiently transport high-speed data over the current GSM and TDMA-based wireless network infrastructures.
Deployment of GPRS networks allows a variety of new applications ranging from mobile e-commerce to mobile corporate VPN access
Deployments of GPRS network has already taken place in several countries in Europe and the far east.
We have learnt that any computer system is made of hardware and software.
The hardware understands a language, which humans cannot understand. So we write programs in high-level language, which is easier for us to understand and remember.
These programs are then fed into a series of tools and OS components to get the desired code that can be used by the machine.
This is known as Language Processing System.
screen speculo is an android App. The main feature of App is to mirror screen between multiple android devices. In this App, the screen of main user’s device will be visible to all other devices. This App will provide two different modes to connect with multiple user. First mode is open mode which allows other users to connect with main user and main user can share screen and media. Second mode is moderated access mode which enable moderator to approve and reject other user’s request that means main user will have all the controls.
The document discusses the 8085 microprocessor, including its pinout, demultiplexing of its address/data bus, and generation of control signals. It describes how the 8085 has a multiplexed address/data bus on pins AD7-AD0 and explains how to use an latch and ALE signal to separate the low-order address. It also shows how to generate separate memory and I/O read and write control signals by combining the RD, WR and IO/M signals using logic gates. Finally, it provides a diagram of an 8085 MPU interfaced with memory and I/O using a latch to demultiplex the bus and logic gates to produce the necessary control signals.
One pass assembler, Two pass assembler,
Advanced Assembler Directives
Index
------
One-pass assembler
Forward Reference
Two-pass assembler using variant-I
Two-pass assembler using variant-II
Advanced Assembler Directives
Design of two pass assembler
A firewall is a network security system that monitors and controls the incoming and outgoing network traffic based on predetermined security rules. Packet filter is a hardware or software designed to block or allow transmission of packets based on criteria such as port, IP address, protocol.
Shopping At Mall without standing in Queue for Bill Payment by Scanning Bar c...Radhika Talaviya
Banking can be defined as the business activity of accepting and safeguarding money owned by other individual and entities, and then lending out this money in order to earn a profit. However, with the passage of time, the activities covered by banking business have widened and now various other services and also offered by banks. The banking services these day, include issuance of debit and credit card, providing safe custody of valuable items, lockers, ATM services and online transfer of fund across the country/world. We have chosen the topic which combine banking process and shopping system.
The document provides information about programming basic computer operations like arithmetic, logic, and input/output operations using machine language and assembly language. It describes machine language and assembly language programming, including the use of pseudo instructions and address symbol tables. It provides examples of programming multiplication, loops, and double precision addition in assembly language.
A stack is a linear data structure in which an element can be inserted or deleted only at one end of the list.
A stack works on the principle of last in first out and is also known as a Last-In-First-Out (LIFO) list.
A bunch of books is one of the common examples of stack. A new book to be added to the bunch is placed at the top and a book to be removed is also taken off from the top.
Therefore, in order to take out the book at the bottom, all the books above it need to be removed from the bunch.
Managers are responsible for controlling and administering organizations and staff. There are typically three levels of managers - workers, first-line managers, and middle/senior managers. Managers play key roles such as setting objectives, making plans, guiding workers, and resolving issues. Effective managers have strong conceptual, human, and technical skills to fulfill their interpersonal, informational, and decision-making duties.
The document discusses various concepts related to relational databases including:
- Primary keys uniquely identify rows in a table. Foreign keys match values in other tables' primary keys.
- Relational databases represent data using relations which have a schema and instances consisting of tuples.
- Relational algebra operations like selection, projection, join, etc. allow querying relational data.
The changes in the surface air temperature,reffered to as the global temperature, brought about by the enhanced green house effect, which is enduced by emmission of greenhouse gases into the air.
Here in my lens, I am throwing light on the life cycle of a girl's life. It starts from when a girl is born in a family extending on to her upbringing to her marriage and then to her pregnancy and delivery. After which, if a girl is born again, the same cycle repeats.
Nanophysics the physics of structures and artefacts with
dimensions in the nanometer range or of
phenomena occurring in nanoseconds. Nanoscience is the study of atoms, molecules and object whose size is of the nanometer scale (1-100nm).
I'm OK, You're OK, by Thomas A Harris MD, is one of the best selling self-help books ever published.It is a practical guide to Transactional Analysis as a method for solving problems in life.
Using recycled concrete aggregates (RCA) for pavements is crucial to achieving sustainability. Implementing RCA for new pavement can minimize carbon footprint, conserve natural resources, reduce harmful emissions, and lower life cycle costs. Compared to natural aggregate (NA), RCA pavement has fewer comprehensive studies and sustainability assessments.
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSIJNSA Journal
The smart irrigation system represents an innovative approach to optimize water usage in agricultural and landscaping practices. The integration of cutting-edge technologies, including sensors, actuators, and data analysis, empowers this system to provide accurate monitoring and control of irrigation processes by leveraging real-time environmental conditions. The main objective of a smart irrigation system is to optimize water efficiency, minimize expenses, and foster the adoption of sustainable water management methods. This paper conducts a systematic risk assessment by exploring the key components/assets and their functionalities in the smart irrigation system. The crucial role of sensors in gathering data on soil moisture, weather patterns, and plant well-being is emphasized in this system. These sensors enable intelligent decision-making in irrigation scheduling and water distribution, leading to enhanced water efficiency and sustainable water management practices. Actuators enable automated control of irrigation devices, ensuring precise and targeted water delivery to plants. Additionally, the paper addresses the potential threat and vulnerabilities associated with smart irrigation systems. It discusses limitations of the system, such as power constraints and computational capabilities, and calculates the potential security risks. The paper suggests possible risk treatment methods for effective secure system operation. In conclusion, the paper emphasizes the significant benefits of implementing smart irrigation systems, including improved water conservation, increased crop yield, and reduced environmental impact. Additionally, based on the security analysis conducted, the paper recommends the implementation of countermeasures and security approaches to address vulnerabilities and ensure the integrity and reliability of the system. By incorporating these measures, smart irrigation technology can revolutionize water management practices in agriculture, promoting sustainability, resource efficiency, and safeguarding against potential security threats.
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELgerogepatton
As digital technology becomes more deeply embedded in power systems, protecting the communication
networks of Smart Grids (SG) has emerged as a critical concern. Distributed Network Protocol 3 (DNP3)
represents a multi-tiered application layer protocol extensively utilized in Supervisory Control and Data
Acquisition (SCADA)-based smart grids to facilitate real-time data gathering and control functionalities.
Robust Intrusion Detection Systems (IDS) are necessary for early threat detection and mitigation because
of the interconnection of these networks, which makes them vulnerable to a variety of cyberattacks. To
solve this issue, this paper develops a hybrid Deep Learning (DL) model specifically designed for intrusion
detection in smart grids. The proposed approach is a combination of the Convolutional Neural Network
(CNN) and the Long-Short-Term Memory algorithms (LSTM). We employed a recent intrusion detection
dataset (DNP3), which focuses on unauthorized commands and Denial of Service (DoS) cyberattacks, to
train and test our model. The results of our experiments show that our CNN-LSTM method is much better
at finding smart grid intrusions than other deep learning algorithms used for classification. In addition,
our proposed approach improves accuracy, precision, recall, and F1 score, achieving a high detection
accuracy rate of 99.50%.
A review on techniques and modelling methodologies used for checking electrom...nooriasukmaningtyas
The proper function of the integrated circuit (IC) in an inhibiting electromagnetic environment has always been a serious concern throughout the decades of revolution in the world of electronics, from disjunct devices to today’s integrated circuit technology, where billions of transistors are combined on a single chip. The automotive industry and smart vehicles in particular, are confronting design issues such as being prone to electromagnetic interference (EMI). Electronic control devices calculate incorrect outputs because of EMI and sensors give misleading values which can prove fatal in case of automotives. In this paper, the authors have non exhaustively tried to review research work concerned with the investigation of EMI in ICs and prediction of this EMI using various modelling methodologies and measurement setups.
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsVictor Morales
K8sGPT is a tool that analyzes and diagnoses Kubernetes clusters. This presentation was used to share the requirements and dependencies to deploy K8sGPT in a local environment.
International Conference on NLP, Artificial Intelligence, Machine Learning an...gerogepatton
International Conference on NLP, Artificial Intelligence, Machine Learning and Applications (NLAIM 2024) offers a premier global platform for exchanging insights and findings in the theory, methodology, and applications of NLP, Artificial Intelligence, Machine Learning, and their applications. The conference seeks substantial contributions across all key domains of NLP, Artificial Intelligence, Machine Learning, and their practical applications, aiming to foster both theoretical advancements and real-world implementations. With a focus on facilitating collaboration between researchers and practitioners from academia and industry, the conference serves as a nexus for sharing the latest developments in the field.
Embedded machine learning-based road conditions and driving behavior monitoringIJECEIAES
Car accident rates have increased in recent years, resulting in losses in human lives, properties, and other financial costs. An embedded machine learning-based system is developed to address this critical issue. The system can monitor road conditions, detect driving patterns, and identify aggressive driving behaviors. The system is based on neural networks trained on a comprehensive dataset of driving events, driving styles, and road conditions. The system effectively detects potential risks and helps mitigate the frequency and impact of accidents. The primary goal is to ensure the safety of drivers and vehicles. Collecting data involved gathering information on three key road events: normal street and normal drive, speed bumps, circular yellow speed bumps, and three aggressive driving actions: sudden start, sudden stop, and sudden entry. The gathered data is processed and analyzed using a machine learning system designed for limited power and memory devices. The developed system resulted in 91.9% accuracy, 93.6% precision, and 92% recall. The achieved inference time on an Arduino Nano 33 BLE Sense with a 32-bit CPU running at 64 MHz is 34 ms and requires 2.6 kB peak RAM and 139.9 kB program flash memory, making it suitable for resource-constrained embedded systems.
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEMHODECEDSIET
Time Division Multiplexing (TDM) is a method of transmitting multiple signals over a single communication channel by dividing the signal into many segments, each having a very short duration of time. These time slots are then allocated to different data streams, allowing multiple signals to share the same transmission medium efficiently. TDM is widely used in telecommunications and data communication systems.
### How TDM Works
1. **Time Slots Allocation**: The core principle of TDM is to assign distinct time slots to each signal. During each time slot, the respective signal is transmitted, and then the process repeats cyclically. For example, if there are four signals to be transmitted, the TDM cycle will divide time into four slots, each assigned to one signal.
2. **Synchronization**: Synchronization is crucial in TDM systems to ensure that the signals are correctly aligned with their respective time slots. Both the transmitter and receiver must be synchronized to avoid any overlap or loss of data. This synchronization is typically maintained by a clock signal that ensures time slots are accurately aligned.
3. **Frame Structure**: TDM data is organized into frames, where each frame consists of a set of time slots. Each frame is repeated at regular intervals, ensuring continuous transmission of data streams. The frame structure helps in managing the data streams and maintaining the synchronization between the transmitter and receiver.
4. **Multiplexer and Demultiplexer**: At the transmitting end, a multiplexer combines multiple input signals into a single composite signal by assigning each signal to a specific time slot. At the receiving end, a demultiplexer separates the composite signal back into individual signals based on their respective time slots.
### Types of TDM
1. **Synchronous TDM**: In synchronous TDM, time slots are pre-assigned to each signal, regardless of whether the signal has data to transmit or not. This can lead to inefficiencies if some time slots remain empty due to the absence of data.
2. **Asynchronous TDM (or Statistical TDM)**: Asynchronous TDM addresses the inefficiencies of synchronous TDM by allocating time slots dynamically based on the presence of data. Time slots are assigned only when there is data to transmit, which optimizes the use of the communication channel.
### Applications of TDM
- **Telecommunications**: TDM is extensively used in telecommunication systems, such as in T1 and E1 lines, where multiple telephone calls are transmitted over a single line by assigning each call to a specific time slot.
- **Digital Audio and Video Broadcasting**: TDM is used in broadcasting systems to transmit multiple audio or video streams over a single channel, ensuring efficient use of bandwidth.
- **Computer Networks**: TDM is used in network protocols and systems to manage the transmission of data from multiple sources over a single network medium.
### Advantages of TDM
- **Efficient Use of Bandwidth**: TDM all
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...IJECEIAES
Climate change's impact on the planet forced the United Nations and governments to promote green energies and electric transportation. The deployments of photovoltaic (PV) and electric vehicle (EV) systems gained stronger momentum due to their numerous advantages over fossil fuel types. The advantages go beyond sustainability to reach financial support and stability. The work in this paper introduces the hybrid system between PV and EV to support industrial and commercial plants. This paper covers the theoretical framework of the proposed hybrid system including the required equation to complete the cost analysis when PV and EV are present. In addition, the proposed design diagram which sets the priorities and requirements of the system is presented. The proposed approach allows setup to advance their power stability, especially during power outages. The presented information supports researchers and plant owners to complete the necessary analysis while promoting the deployment of clean energy. The result of a case study that represents a dairy milk farmer supports the theoretical works and highlights its advanced benefits to existing plants. The short return on investment of the proposed approach supports the paper's novelty approach for the sustainable electrical system. In addition, the proposed system allows for an isolated power setup without the need for a transmission line which enhances the safety of the electrical network
Using recycled concrete aggregates (RCA) for pavements is crucial to achieving sustainability. Implementing RCA for new pavement can minimize carbon footprint, conserve natural resources, reduce harmful emissions, and lower life cycle costs. Compared to natural aggregate (NA), RCA pavement has fewer comprehensive studies and sustainability assessments.
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...IJECEIAES
Medical image analysis has witnessed significant advancements with deep learning techniques. In the domain of brain tumor segmentation, the ability to
precisely delineate tumor boundaries from magnetic resonance imaging (MRI)
scans holds profound implications for diagnosis. This study presents an ensemble convolutional neural network (CNN) with transfer learning, integrating
the state-of-the-art Deeplabv3+ architecture with the ResNet18 backbone. The
model is rigorously trained and evaluated, exhibiting remarkable performance
metrics, including an impressive global accuracy of 99.286%, a high-class accuracy of 82.191%, a mean intersection over union (IoU) of 79.900%, a weighted
IoU of 98.620%, and a Boundary F1 (BF) score of 83.303%. Notably, a detailed comparative analysis with existing methods showcases the superiority of
our proposed model. These findings underscore the model’s competence in precise brain tumor localization, underscoring its potential to revolutionize medical
image analysis and enhance healthcare outcomes. This research paves the way
for future exploration and optimization of advanced CNN models in medical
imaging, emphasizing addressing false positives and resource efficiency.
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Classes, Objects and Method - Object Oriented Programming with Java
1. SHREE SWAMI ATMANAND SARASWATI INSTITUTE
OF TECHNOLOGY
Object Oriented Programming with JAVA(2150704)
PREPARED BY: (Group:2)
Bhumi Aghera(130760107001)
Monika Dudhat(130760107007)
Radhika Talaviya(130760107029)
Rajvi Vaghasiya(130760107031)
Classes, Objects and Method
GUIDED BY:
Prof. Vasundhara Uchhula
Prof. Hardik Nariya
2. content
• Class
• Object
• Object reference
• Constructor
• Overloading constructor
• Method overloading
• Argument passing and returning object
• Recursion
• New operator
• ‘this’ and ‘static’ keyword
• Finalize() method
• Access control
• Nested and Inner classes
• Anonymous inner class
• Abstract class
3. Class
• Class is template for an object and object is instance of a class.
• Classes may contain only code or only data, most real-world classes contain both.
• Class is declared by use of the class keyword.
• The data or variables, defined within a class are called instance variables.
• The code is contained within methods.
• Collectively, the methods and variables defined within a class are called member of the class.
• In most classes, the instance variables are acted upon and accessed by the methods defined
for that class .
• Thus, it is the method that determine how a class data can be used.
• The general form of a class definition is as follows:
class classname {
type instance-variable1;
type instance-variable2;
type methodname1(parameter-list) {
//body of method
}
type methodname2(parameter-list){
//body of method
}
}
4. A simple class example:
class Box
{
double width;
double height;
double depth;
}
• As stated, a class defines a new type of data. In this case, the new data type is called Box. The
important point is that a class declaration only creates a template; it does not create actual
object.
• Thus, the preceding code does not cause any object of type Box to come into existence.
5. Object
• When we create a class, we are creating a new data type. we can use this type to declare
objects of that type.
• However, obtaining objects of a class is a two-step process.
• First, we must declare a variable of the class type. This variable does not define an object.
Instead, it is simply a variable that can refer to an object.
• Second, we must acquire an actual, physical copy of the object and assign it to that variable.
We can do this using new operator. The new operator dynamically allocates memory for an
object and returns a reference to it.
• In preceding sample programs, a line similar to the following is used to declare an object type
Box:
Box mybox = new Box();
• This statement combines the two steps. It can be rewritten like this to show each step:
Box mybox; // declare reference to object
mybox = new Box(); // allocate a box object
6. Object reference
• We can assign value of one object reference variable to another reference variable.
• Reference variable used to store the address of the variables.
• Reference variable will not create distinct copies of objects.
• All reference variables are referring to same object.
• Assigning object reference variables does not allocate memory.
• For example,
Box b1 = new Box();
Box b2 = b1;
• b1 is reference variable which contain the address of actual Box object.
• b2 is another reference variable.
• b2 is initialized with b1 means, b1 and b2 both are referring same object, thus it does not
create duplicate object, nor it allocate extra memory.
7. Constructors
• Constructor is a special type of method that is used to initialize the object.
• A constructor has same name as the class in which it resides and is syntactically similar to a
method.
• Once defined, the constructor is automatically called immediately after the object is created,
before the new operator completes.
• Constructors have no return type, not even void. This is because the implicit return type of
class constructor is the class type itself.
• There are two type of Constructors:
1) Default Constructor
2) Parameterized Constructor
8. Default Constructor
• A Constructor that have no parameter is known as default Constructor.
• Syntax of default Constructor:
<class_name>(){ }
• For example,
class Box
{ double h,w,d;
Box() // default constructor
{ System.out.println(“constructing Box”);
h=w=d=10;
}
double volume()
{ return w*h*d;
}
}
class Boxdemo
{ public static void main(String args[])
{ Box b = new Box();
System.out.println(“volume is
”+b.volume);
}
}
Output:
constructing Box
volume is 1000.0
9. Parameterized constructor
• A Constructor that have parameter is known as parameterized Constructor.
• Parameterized Constructor is used to provide different values to the distinct objects of class.
• For example,
class Box
{
double h,w,d;
Box(double height,double width,double depth) // parameterized constructor
{
System.out.println(“constructing Box”);
h = height;
w = width;
d = depth ;
}
10. Parameterized constructor
double volume() {
return w*h*d;
}
}
class Boxdemo {
public static void main(String args[]) {
Box b = new Box(10,20,15);
System.out.println(“volume is ”+b.volume);
}
}
Output:
constructing Box
volume is 3000.0
11. Overloading Constructors
• For most real-world classes that you create, overloaded constructors will be the norm, not the
exception.
• The proper overloaded constructor is called based upon the parameters specified when new is
executed.
• Example:
class Box {
double width, height, depth;
Box(double w, double h, double d) {
width=w; height=h; depth=d;
}
Box() {
width=-1; height=-1; depth=-1;
}
12. Overloading Constructors
Box(double len) {
width=height=depth=len;
}
double volume() {
return width*height*depth;
}
}
public class Overload {
public static void main(String[] args) {
Box mybox1 = new Box(10,20,30);
Box mybox2 = new Box();
Box mybox3 = new Box(5);
double vol;
vol = mybox1.volume();
13. Overloading Constructors
system.out.println("volume of mybox1 is"+vol);
vol = mybox2.volume();
system.out.println("volume of mybox2 is"+vol);
vol = mybox3.volume();
system.out.println("volume of mybox3 is"+vol);
}
}
Output is:
Volume of mybox1 is 6000.0
Volume of mybox2 is -1.0
Volume of mybox3 is 125.
14. Method Overloading
• In java it is possible to define two or more methods within the same class that share the same
name, as long as their parameter declarations are different.
• When this is the case, the method are said to be overloaded, and the process is referred to as
method overloading.
• Method overloading is one of the ways that Java implements polymorphism.
• Overloaded methods must differ in the type and/ or number of their parameters.
• While overloaded methods may have different return types, the return type alone is
insufficient to distinguish two versions of a method.
• When Java encounters call to an overloaded method, it simply executes the version of the
method whose parameters match the arguments used in the call.
Example:
class Area
{ int r,b,a;
15. Method Overloading
void area(int a)
{ return (a*a);
}
void area(int a,int d)
{ return (a*b);
}
void area(int a,int b,int r)
{ return (a*b*r);
}
}
class mainclass
{ public void main(string[] args)
{ area a= new area();
system.out.println(“area of square is: “+a.area(2));
system.out.println(“area of rectangle is: “+a.area(2,3));
16. Method Overloading
system.out.println(“area of cube is: “+a.area(2,3,5));
}
}
Output:
Area of square is: 4
Area of rectangle is: 6
Area of cube is: 30
• When an overloaded method is called, Java looks for a match between the arguments used to
call the method and the method’s parameters. However, this match need not always be exact.
• In some cases Java’s automatic type conversions can play a role in overload resolution.
17. Passing an argument
• There are two ways that a computer language can pass an argument to a subroutine. The first
way is call-by-value.
• This method copies the value of an argument into the formal parameter of the subroutine.
Therefore, changes made to the parameter of the subroutine have no effect on the argument.
• In java, when you pass a simple type to a method, it is passed by value. Thus, what occurs to
the parameter that receives the argument has no effect outside the method.
• Example:
// simple types are passed by value.
class test
{ void meth(int i , int j)
{ i * = 2;
j/ =2;
}
}
18. Passing an argument
class callbyvalue
{
public static void main (string args[ ] )
{
test ob = new test ();
int a = 15, b = 20;
system. out . println("'a and b before call: "' + a + "" "" + b);
ob. meth( a, b);
system.out.printin("a and b after call: " + a + "" "" = b);
}
}
Output:
a and b before call: 15 20
a and b after call: 15 20
19. Passing an argument
• The second way an argument can be passed is call-by-reference. In this method, a reference to
an argument (not the value of the argument) is passed to the parameter. Inside the subroutine,
this reference is used to access the actual argument specified in the call. This means that
changes made to the parameter will affect the argument used to call the subroutine.
• when create a variable of a class type, then required only creating a reference to an object.
• Example:
/ / objects are passed by reference.
class test
{ int a, b;
test (int i, int j)
{ a= i;
b=j;
}
void meth(test o)
20. Passing an argument
{ o.a * = 2; o.b / = 2;
}
}
Class Callbyref
{ public static void main (string args [ ] )
{ test ob = new test ( 15, 20);
system.out.println ( "ob.a and ob. b before call: "+ ob.a + " " + ob.b) ;
ob.meth (ob);
system.out.println ( " ob.a and ob . b after call: " + ob. a + " " + ob.b ) ;
}
}
Output:
ob. a and ob.b before call: 15 20
ob. a and ob.b after call: 30 10
21. Returning objects
• A method can return any type of data. Including class types that you create. For example, in
the following program, the incrbyten() method returns an object in which the value of a is ten
greater than it is in the invoking object.
• Example:
class test
{ int a;
test (int i)
{ a = i :
}
test incrbyten ()
{ test temp = new test (a+10);
return temp;
}
}
22. Returning objects
class retob
{ public static void main (string args []) {
test ob1 = new test(2);
test ob2;
ob2 = ob1 . incrbyten ();
system.out.println("ob1 . a: " + ob1.a) ;
system.out.println("ob2 . a: " + ob2 . a) ;
ob2 = ob2 . incrbyten() ;
system.out.println (""ob2 . a after second increase: ""+ ob2. a ) ;
}
}
Output:
ob1.a: 2
ob2.a: 12
ob2.a after second increase: 22
23. Recursion
• Recursion is the process of defining something in terms of itself. As it relates to java
programming, recursion is the attribute that allows a method to call itself. A method that calls
itself is said to be recursive.
• The classic example of recursion is the computation of the factorial of a number. The factorial
of a number N is the product of all the whole numbers between 1 and n.
• Example:
class factorial
{ int fact (int n)
{ int result ;
if(n==1)
{ return 1;
}
result = fact(n-1) * n;
return result;
24. Recursion
}
}
class recursion
{ public static void main (string args[])
{ factorial f = new factorial ();
system.out.printin("factorial of 3 is " + f.fact(3)) ;
system.out.printin("factorial of 4 is " + f.fact(4));
system.out.printin("factorial of 5 is " + f.fact(5));
}
}
Output:
factorial of 3 is 6
factorial of 4 is 24
factorial of 5 is 120
25. Recursion
• As each recursive call returns, the old local variables and parameters are removed from the
stack, and execution resumes at the point of the call inside the method.
• Recursion methods could be said to “telescope” out and back.
• Recursive versions of many routines may execute a bit more slowly than the iterative
equivalent because of the added overhead of the additional functiuon calls.
• Many recursive calls to a method could cause a stack. Because storage for parameters and
local variables is on the stack and each new call creates a new copy of these variables, it is
possible that the stack could be exhausted.
• The main advantage to recursive methods is that they can be used to create clearer and
simpler versions of several algorithms than can their iterative relation.
• For example, the QuickSort sorting algorithms is quite difficult to implement in an iterative
way. Some probles, especially AI-related ones, seem to lend themselves to recursive solution.
26. New operator
• The new operator dynamically allocates memory for an object during run time. It has
this general form:
class-var = new classname( );
• Here, class-var is a variable of the class type being created. The classname is the name of
the class that is being instantiated. The class name followed by parentheses specifies
the constructor for the class.
• The advantage of this approach is that your program can create as many or as few objects as it
needs during the execution of your program.
• For example: Box b1 = new Box();
Box b2 = b1;
27. New operator
• b2 is being assigned a reference to a copy of the object referred to by b1. b1 and b2 will both
refer to the same object. The assignment ofb1 to b2 did not allocate any memory or copy any
part of the original object. It simply makes b2 refer to the same object as does b1. Thus, any
changes made to the object through b2 will affect the object to which b1 is referring, since
they are the same object.
• This situation is depicted here:
b1
b2
width
height
depth
Box object
28. New operator
• Although b1 and b2 both refer to the same object, they are not linked in any other way. For
example, a subsequent assignment to b1 will simply unhook b1 from the original object
without affecting the object or affecting b2. For example:
b1 = null;
• Here, b1 has been set to null, but b2 still points to the original object.
• When you assign one object reference variable to another object reference variable, you are
not creating a copy of the object, you are only making a copy of the reference.
29. ‘this’ keyword
• this is a reference variable that refers to the current object.
• Usage of java this keyword
i. this keyword can be used to refer current class instance variable.
ii. this() can be used to invoke current class constructor.
iii. this keyword can be used to invoke current class method (implicitly)
iv. this can be passed as an argument in the method call.
v. this can be passed as argument in the constructor call.
vi. this keyword can also be used to return the current class instance.
30. ‘this’ keyword
• this keyword is used from any method or constructor to refer to the current object that calls a
method or invokes constructor .
• Syntax: this.field
31. ‘static’ keyword
• The static keyword in java is used for memory management mainly. We can apply
java static keyword with variables, methods, blocks and nested class.
• The static keyword belongs to the class than instance of the class.
• The static can be:
i. Variable (also known as class variable)
ii. Method (also known as class method)
iii. Block
iv. Nested class
32. Java static method
• If you apply static keyword with any method, it is known as static method.
• A static method belongs to the class rather than object of a class.
• A static method can be invoked without the need for creating an instance of a class.
• static method can access static data member and can change the value of it.
Restrictions for static method
• The static method can not use non static data member or call non-static method directly.
• this and super cannot be used in static context.
33. Java static variable
• If you declare any variable as static, it is known static variable.
• The static variable can be used to refer the common property of all objects (that is not unique
for each object) e.g. company name of employee, college name of students etc.
• The static variable gets memory only once in class area at the time of class loading.
Java static block
• It used to initialize the static data member.
• It is executed before main method at the time of class loading.
34. finalize() method
• Sometimes an object will need to perform some action when it is destroyed.
• For example, if an object is holding some non-java resource such as a file handle or window
character font, then you might want to make sure these resources are freed before an object is
destroyed.
• To handle such situations, java provides a mechanism called finalization. By using
finalization, you can define specific actions that will occur when an object is just about to be
reclaimed by the garbage collector.
• To add a finalizer to a class, you simply define the finalize() method. The java run time calls
that method whenever it is about to recycle an object of that class. Inside the finalize() method
you will specify those actions that must be performed before an object is destroyed.
35. finalize() method
• The garbage collector runs periodically, checking for objects that are no longer referenced by
any running state or indirectly through other referenced objects. Right before an asset is freed,
the java run time calls the finalize() method on the object.
• The finalize() method has this general form:
protected void finalize()
{
// finalization code here
}
• Here, the keyword protected is a specifier that prevents access to finalize() by code defined
outside its class.
36. Access control
• Through encapsulation, you can control what parts of a program can access the members of a
class. By controlling access, you can prevent misuse.
• For example, allowing access to data only through a well-defined set of methods, you can
prevent the misuse of that data.
• Java’s access specifiers are public, private, and protected. Java also defines a default access
level.
• protected applies only when inheritance is involved.
• When a member of a class is modified by the public specifier, then that member can be
accessed by any other code in your program.
37. Access control
• When a member of a class is specified as private, then that member can only be accessed by
other members of its class.
• When no access specifier is used, then by default the member of a class is public within its
own package, but cannot be accessed outside of its package.
• An access specifier precedes the rest of a member’s type specification. That is, it must begin a
member’s declaration statement. Here is an example:
public int i;
private double j;
private int myMethod(int a, char b) {//…}
38. Access control
class Test {
int a;
public int b;
private int c;
void setc(int i) {
c = i;
}
int getc() {
return c;
}
}
class AccessTest {
public static void main(String args[]) {
Test ob = new Test ();
ob.a = 10;
ob.b = 20;
ob.setc(100);
System.out.println(“a, b, and c:
“ + ob.a + ” “ + ob.b+
“ “+ ob.getc());
}
}
39. Access control
• Inside the Test class, a uses default access, which for this example is the same as specifying
public. b is explicitly specified as public.
• Member c is given private access. This means that it cannot be accessed by code outside of its
class. So, inside the AccessTest class, c cannot be used directly.
• It must be accessed through its public methods: setc() and getc(). If you were to remove the
comment symbol from the beginning of the following line;
ob.c = 100;
40. Nested and Inner Classes
• It is possible to define a class within another class; such classes are known as nested classes.
• There are two types of nested classes
1) Static
2) Non-static
• A static nested class is one which has the static modifier applied. Because it is static, it must
access the members of its enclosing class through an object. Because of this, static nested
classes are seldom used.
• An inner class is a non-static nested class. It has access to all of the variables and methods of
its outer class and may refer to them directly as the non-static member of the outer class.
41. Nested and Inner Classes
Demonstrate an inner class.
Class outer {
int outer_x=100;
void test() {
Inner inner = new Inner();
inner.display();
}
//this is an inner class
class Inner {
void display(){
System.out.print(“display: outer_x = ”+
outer_x );
}
}
}
class InnerClassDemo {
public static voidmain(Stringargs[]) {
Outer outer =new Outer();
outer.test();
}
}
Output:
display: outer_x = 100
42. Anonymous Inner class
• Inner class without a name is called Anonymous Inner class.
• Anonymous Inner class is a subclass of its original class.
Example:
class Test {
void show() {
System.out.print(“Hello”);
}
}
class AnonDemo {
public static void main(String args[]) {
class AnonDemo {
public static void main(String args[]) {
Test t =new test();
{
void show() {
System.out.print(“Hi,from main”);
}
};
t.show();
}
}
43. Abstract Class
• Sometimes, we want to define a super class that only declare structure without providing
implementation of every method. It is left to the subclass to fill the details such a superclass is
called abstract class.
• Any class that contains one or more abstract method must be declared abstract.
• There can be no object of abstract class.
• We cannot declare abstract constructor or abstract static method.
• Any subclass of an abstract class must either implement all of the abstract method in the
superclass or be itself declared abstract.
• Syntax for abstract method: abstract type name(parameter-list);
• Syntax for abstract class: abstract classname{
//abstract method or concrete method;
}
44. Abstract Class
• It must be possible to create a reference to an abstract class so that it can be used to point to a
subclass object.
• Example:
//superclass
abstract class Figure {
double dim1,dim2;
figure(double a, double b) {
dim1=a;
dim2=b;
}
abstract double area(); //abstract method;
}
//subclass
class Rectangle extends Figure {
Rectangle(double a, double b) {
super(a,b);
}
double area() {
return dim1*dim2;
}
}
45. Abstract Class
class maindemo {
public static void main(String args[]) {
Figure f =new Figure(10,10); // illegal
Rectangle r =new Rectangle(9,5);
Figure f; // This is ok, no object is created
f = r;
System.out.println(“Area for rectangle is ”+ f.area() );
}
}
Output:
Area for rectangle is 45