This document provides an overview of data types, variables, and expressions in Java. It discusses the different primitive data types in Java like int, float, boolean, and char. It explains how to declare variables of different types and assign values to them. The document also covers string concatenation, escape sequences, type conversion, and arithmetic expressions in Java. Key concepts covered include compatible data types for assignments, implicit type casting in expressions, and operator precedence rules.
This document provides an overview of Java programming basics, including application structure, data types, variables, expressions, operators, and comments. Key points include: all Java programs must contain at least one class; variables are used to store and name data; the basic data types are byte, short, int, long, float, double, char, and boolean; expressions use operators to manipulate data; and comments are used to explain code to others.
The document discusses key concepts in C# programming including data types, operators, control flow statements, methods, classes, arrays, and more. It provides definitions and examples of common terms like namespaces, classes, methods, operators, loops, and exceptions. Type conversion methods in C# are also summarized in a table listing common conversion functions.
The document discusses variables, constants, data types, calculations, and formatting values in Visual Basic. It defines variables and constants, lists common data types, and explains how to perform calculations using variables and constants of different data types. It also covers declaring variables, naming conventions, implicit and explicit conversions, and formatting values for display.
Lexical analyzer, tokenizer, scanner, or lexer is a function that is invoked by the syntax analyzer. This function returns the nxt lexicon or word in the source file.
C++ provides several fundamental and derived data types to store and represent different types of data. Fundamental data types include integers, characters, floats, doubles, and void. Integers can be further classified as short, int, long and modified with signed or unsigned. Characters can also be signed or unsigned. Floats and doubles represent real numbers with different levels of precision. Derived data types include arrays to store multiple values of the same type, structures to group different data types, unions to access memory in different types, enumerations to define named integer constants, classes to define user-defined types with methods and pointers to reference memory locations.
This document discusses key concepts in Java programming including classes, methods, parameters, and invoking methods. It explains that a program consists of classes, a class contains methods, and a method contains statements. Methods can take parameters, which are initialized when the method is called and allow passing in values. Parameters act similarly to local variables but are declared in the method signature.
Generic classes and interfaces allow type parameters that act as placeholders for type arguments. This allows a single class implementation to work for multiple types, catching errors at compile time. Wildcard types like ? extends Number and ? super Integer allow more flexible usage of generics by supporting subtyping.
This document provides an overview of key concepts related to writing classes in Java, including:
- Defining classes to create custom objects with state (data) and behaviors (methods)
- Encapsulation and using access modifiers like public and private to control visibility
- Declaring methods, parameters, and return types
- Overloading methods by having multiple methods with the same name but different parameters
- Constructors for initializing new objects
This document provides an overview of Java programming basics, including application structure, data types, variables, expressions, operators, and comments. Key points include: all Java programs must contain at least one class; variables are used to store and name data; the basic data types are byte, short, int, long, float, double, char, and boolean; expressions use operators to manipulate data; and comments are used to explain code to others.
The document discusses key concepts in C# programming including data types, operators, control flow statements, methods, classes, arrays, and more. It provides definitions and examples of common terms like namespaces, classes, methods, operators, loops, and exceptions. Type conversion methods in C# are also summarized in a table listing common conversion functions.
The document discusses variables, constants, data types, calculations, and formatting values in Visual Basic. It defines variables and constants, lists common data types, and explains how to perform calculations using variables and constants of different data types. It also covers declaring variables, naming conventions, implicit and explicit conversions, and formatting values for display.
Lexical analyzer, tokenizer, scanner, or lexer is a function that is invoked by the syntax analyzer. This function returns the nxt lexicon or word in the source file.
C++ provides several fundamental and derived data types to store and represent different types of data. Fundamental data types include integers, characters, floats, doubles, and void. Integers can be further classified as short, int, long and modified with signed or unsigned. Characters can also be signed or unsigned. Floats and doubles represent real numbers with different levels of precision. Derived data types include arrays to store multiple values of the same type, structures to group different data types, unions to access memory in different types, enumerations to define named integer constants, classes to define user-defined types with methods and pointers to reference memory locations.
This document discusses key concepts in Java programming including classes, methods, parameters, and invoking methods. It explains that a program consists of classes, a class contains methods, and a method contains statements. Methods can take parameters, which are initialized when the method is called and allow passing in values. Parameters act similarly to local variables but are declared in the method signature.
Generic classes and interfaces allow type parameters that act as placeholders for type arguments. This allows a single class implementation to work for multiple types, catching errors at compile time. Wildcard types like ? extends Number and ? super Integer allow more flexible usage of generics by supporting subtyping.
This document provides an overview of key concepts related to writing classes in Java, including:
- Defining classes to create custom objects with state (data) and behaviors (methods)
- Encapsulation and using access modifiers like public and private to control visibility
- Declaring methods, parameters, and return types
- Overloading methods by having multiple methods with the same name but different parameters
- Constructors for initializing new objects
The document discusses the eight primitive data types in Java - boolean, char, byte, short, int, long, float, and double. It explains what each type is used for, their possible value ranges, and when to use each type. Key points covered include int being the preferred integer type, double the preferred real number type, and the importance of declaring variables before use and giving them initial values.
C is a general-purpose programming language developed in the 1970s at Bell Labs. It was designed and written by Dennis Ritchie as a replacement for B programming language. C is a procedural language but features object-oriented programming. Major parts of popular operating systems like Windows and Linux are written in C. It is also commonly used to program devices like microwaves, washing machines, and digital cameras. Key aspects of C include variables, constants, keywords, data types, operators, and control flow statements.
The document provides an overview of key Python concepts including variables, data types, operators, formatting numbers, and taking user input. It explains that variables store values in memory and have naming rules. The main data types are int, float, and string, and numbers can be formatted using specifiers like .2f. Operators allow mathematical operations and comparisons, while input() reads user keyboard input as a string.
The document provides an overview of Strings and StringBuilders in Java. It discusses Strings as immutable objects and how StringBuilders can be more efficient for modifying strings. It also covers common String and StringBuilder methods, when to use each, and exceptions in Java using try/catch blocks.
The document discusses greedy algorithms and matroids. It provides examples of problems that can be solved using greedy approaches, including sorting an array, the coin change problem, and activity selection. It defines key aspects of greedy algorithms like the greedy choice property and optimal substructure. Huffman coding is presented as an application that constructs optimal prefix codes. Finally, it introduces matroids as an abstract structure related to problems solvable by greedy methods.
1) Variables are used in programming to store and manipulate data values. They must be declared with a name and data type.
2) Variables can be initialized during or after declaration by assigning them a value. User input can be obtained and assigned to variables using functions like Console.ReadLine().
3) Constants are variables whose values cannot change once declared, while the scope of a variable determines where it can be accessed within a program.
This document discusses data types and type conversion in Java. It describes primitive and non-primitive data types, including their storage sizes and value ranges. It explains widening and narrowing type conversion, and how coercion can occur in expressions. Relational and boolean expressions are also summarized, including logical operators that can combine boolean expressions.
This document provides an overview of JavaScript, including:
- JavaScript is a lightweight, interpreted programming language that is complementary to and integrated with HTML and Java.
- JavaScript code is placed within <script> tags and can go in the <head> or <body> section of an HTML page.
- JavaScript supports various data types, variables, operators, and comments. It is case sensitive.
- Key JavaScript concepts covered include data types, variables, scope, reserved words, arithmetic operators, comparison operators, logical operators, and bitwise operators.
This document provides an overview of JavaScript including:
- JavaScript is a lightweight, interpreted programming language designed for creating network-centric applications. It is complementary to and integrated with HTML.
- JavaScript code is placed within <script> tags in an HTML document and can be placed in the <head> or <body> sections.
- JavaScript is case sensitive, ignores whitespace, and semicolons are optional. It supports various data types, variables, operators, control structures like if/else statements, loops and functions.
- Functions are defined using the function keyword and parameters can be passed to functions. Exceptions can be handled using try/catch blocks.
- Common JavaScript statements include if/else, switch, while,
Lexical Analysis, Tokens, Patterns, Lexemes, Example pattern, Stages of a Lexical Analyzer, Regular expressions to the lexical analysis, Implementation of Lexical Analyzer, Lexical analyzer: use as generator.
Data types in java | What is Datatypes in Java | Learning with RD | Created b...rahuldaredia21
In this presentation , i will present a what are the datatypes in java? in brief and use easy world to understand easily about datatype but more important think in this presentation is diagram because any types of topic like In Byte understand in theory but easily understand in only diagrams and all about details of byte and also in case all datatypes in java give understand in diagrams then also watch video on youtube to understand more about datatypes link in this description .
https://youtu.be/pOBS9wBXVjY
click on link and watch this video understand datatypes easily.
THANK YOU
This slide begins your formal investigation of the C# programming language by presenting a number
of bite-sized, stand-alone topics you must be comfortable with as you explore the .NET Framework.
Type specifiers in Common Lisp allow specifying the type of data. Standard type specifiers include symbols for types like number, string, array. Type specifiers can also be lists to further specify element types, dimensions, etc. New type specifiers can be defined using deftype. Functions like coerce and upgraded-array-element-type handle type conversions.
Every value in Java has a data type. Java supports two kinds of data types: primitive data types and reference data types. Primitive data types represent atomic, indivisible values. Java has eight Numeric data types: byte, short, int,
An operator is a symbol that is used to perform some type of computation on its operands. Java contains a rich set of
operators. Operators are categorized as unary, binary, or ternary based on the number of operands they take. They are categorized as arithmetic, relational, logical, etc. based on the operation they perform on their operands.
long, float, double, char, and boolean. Literals of primitive data types are constants. Reference data types represent
references of objects in memory. Java is a statically typed programming language. That is, it checks the data types of all values at compile time.
Predicates in Common Lisp are functions that test conditions and return true or false. There are different types of predicates including data type predicates to check types, equality predicates like eq and equal to compare objects, and logical operators like and, or, and not. Specific predicates test for individual data types like numberp, listp, symbolp. Subtypep checks if one type is a subtype of another.
The document discusses various data types in VB.net including Boolean, integer, floating point numbers, strings, chars, and dates. It provides examples of declaring and using variables of each data type. It also briefly discusses operators in VB.net, listing arithmetic, comparison, logical/bitwise, and assignment operators and providing examples of each.
This document provides an overview of basic Java programming concepts including:
- Variable types such as primitives (int, double, char etc.), identifiers, and constants.
- Declaring and assigning values to variables including literals, compatible data types, and type casting.
- Operators for arithmetic, assignment, increment/decrement, and precedence. Errors from division by zero or incompatible types are discussed.
- Strings, escape sequences, and concatenation.
The document discusses operators and casts in C#. It covers various types of operators like arithmetic, comparison, conditional, etc. It explains implicit and explicit type conversions between primitive and reference types. It also discusses overloading operators for custom types and implementing user-defined casts.
This document provides an overview of C# data types, operators, expressions, and statements. It describes primitive data types like integers, floats, booleans, characters, and strings. It also covers literals for representing values of these types. Additionally, it discusses various categories of operators in C# like arithmetic, logical, comparison, assignment, and bitwise operators. Examples are provided to demonstrate how to use each data type and operator.
The document discusses the eight primitive data types in Java - boolean, char, byte, short, int, long, float, and double. It explains what each type is used for, their possible value ranges, and when to use each type. Key points covered include int being the preferred integer type, double the preferred real number type, and the importance of declaring variables before use and giving them initial values.
C is a general-purpose programming language developed in the 1970s at Bell Labs. It was designed and written by Dennis Ritchie as a replacement for B programming language. C is a procedural language but features object-oriented programming. Major parts of popular operating systems like Windows and Linux are written in C. It is also commonly used to program devices like microwaves, washing machines, and digital cameras. Key aspects of C include variables, constants, keywords, data types, operators, and control flow statements.
The document provides an overview of key Python concepts including variables, data types, operators, formatting numbers, and taking user input. It explains that variables store values in memory and have naming rules. The main data types are int, float, and string, and numbers can be formatted using specifiers like .2f. Operators allow mathematical operations and comparisons, while input() reads user keyboard input as a string.
The document provides an overview of Strings and StringBuilders in Java. It discusses Strings as immutable objects and how StringBuilders can be more efficient for modifying strings. It also covers common String and StringBuilder methods, when to use each, and exceptions in Java using try/catch blocks.
The document discusses greedy algorithms and matroids. It provides examples of problems that can be solved using greedy approaches, including sorting an array, the coin change problem, and activity selection. It defines key aspects of greedy algorithms like the greedy choice property and optimal substructure. Huffman coding is presented as an application that constructs optimal prefix codes. Finally, it introduces matroids as an abstract structure related to problems solvable by greedy methods.
1) Variables are used in programming to store and manipulate data values. They must be declared with a name and data type.
2) Variables can be initialized during or after declaration by assigning them a value. User input can be obtained and assigned to variables using functions like Console.ReadLine().
3) Constants are variables whose values cannot change once declared, while the scope of a variable determines where it can be accessed within a program.
This document discusses data types and type conversion in Java. It describes primitive and non-primitive data types, including their storage sizes and value ranges. It explains widening and narrowing type conversion, and how coercion can occur in expressions. Relational and boolean expressions are also summarized, including logical operators that can combine boolean expressions.
This document provides an overview of JavaScript, including:
- JavaScript is a lightweight, interpreted programming language that is complementary to and integrated with HTML and Java.
- JavaScript code is placed within <script> tags and can go in the <head> or <body> section of an HTML page.
- JavaScript supports various data types, variables, operators, and comments. It is case sensitive.
- Key JavaScript concepts covered include data types, variables, scope, reserved words, arithmetic operators, comparison operators, logical operators, and bitwise operators.
This document provides an overview of JavaScript including:
- JavaScript is a lightweight, interpreted programming language designed for creating network-centric applications. It is complementary to and integrated with HTML.
- JavaScript code is placed within <script> tags in an HTML document and can be placed in the <head> or <body> sections.
- JavaScript is case sensitive, ignores whitespace, and semicolons are optional. It supports various data types, variables, operators, control structures like if/else statements, loops and functions.
- Functions are defined using the function keyword and parameters can be passed to functions. Exceptions can be handled using try/catch blocks.
- Common JavaScript statements include if/else, switch, while,
Lexical Analysis, Tokens, Patterns, Lexemes, Example pattern, Stages of a Lexical Analyzer, Regular expressions to the lexical analysis, Implementation of Lexical Analyzer, Lexical analyzer: use as generator.
Data types in java | What is Datatypes in Java | Learning with RD | Created b...rahuldaredia21
In this presentation , i will present a what are the datatypes in java? in brief and use easy world to understand easily about datatype but more important think in this presentation is diagram because any types of topic like In Byte understand in theory but easily understand in only diagrams and all about details of byte and also in case all datatypes in java give understand in diagrams then also watch video on youtube to understand more about datatypes link in this description .
https://youtu.be/pOBS9wBXVjY
click on link and watch this video understand datatypes easily.
THANK YOU
This slide begins your formal investigation of the C# programming language by presenting a number
of bite-sized, stand-alone topics you must be comfortable with as you explore the .NET Framework.
Type specifiers in Common Lisp allow specifying the type of data. Standard type specifiers include symbols for types like number, string, array. Type specifiers can also be lists to further specify element types, dimensions, etc. New type specifiers can be defined using deftype. Functions like coerce and upgraded-array-element-type handle type conversions.
Every value in Java has a data type. Java supports two kinds of data types: primitive data types and reference data types. Primitive data types represent atomic, indivisible values. Java has eight Numeric data types: byte, short, int,
An operator is a symbol that is used to perform some type of computation on its operands. Java contains a rich set of
operators. Operators are categorized as unary, binary, or ternary based on the number of operands they take. They are categorized as arithmetic, relational, logical, etc. based on the operation they perform on their operands.
long, float, double, char, and boolean. Literals of primitive data types are constants. Reference data types represent
references of objects in memory. Java is a statically typed programming language. That is, it checks the data types of all values at compile time.
Predicates in Common Lisp are functions that test conditions and return true or false. There are different types of predicates including data type predicates to check types, equality predicates like eq and equal to compare objects, and logical operators like and, or, and not. Specific predicates test for individual data types like numberp, listp, symbolp. Subtypep checks if one type is a subtype of another.
The document discusses various data types in VB.net including Boolean, integer, floating point numbers, strings, chars, and dates. It provides examples of declaring and using variables of each data type. It also briefly discusses operators in VB.net, listing arithmetic, comparison, logical/bitwise, and assignment operators and providing examples of each.
This document provides an overview of basic Java programming concepts including:
- Variable types such as primitives (int, double, char etc.), identifiers, and constants.
- Declaring and assigning values to variables including literals, compatible data types, and type casting.
- Operators for arithmetic, assignment, increment/decrement, and precedence. Errors from division by zero or incompatible types are discussed.
- Strings, escape sequences, and concatenation.
The document discusses operators and casts in C#. It covers various types of operators like arithmetic, comparison, conditional, etc. It explains implicit and explicit type conversions between primitive and reference types. It also discusses overloading operators for custom types and implementing user-defined casts.
This document provides an overview of C# data types, operators, expressions, and statements. It describes primitive data types like integers, floats, booleans, characters, and strings. It also covers literals for representing values of these types. Additionally, it discusses various categories of operators in C# like arithmetic, logical, comparison, assignment, and bitwise operators. Examples are provided to demonstrate how to use each data type and operator.
The document discusses key concepts in C# programming including data types, operators, control flow statements, methods, classes, and arrays. It provides examples and descriptions of common language elements like namespaces, classes, methods, variables, operators, loops, and conditional statements. Type conversion methods and how to accept user input and initialize arrays are also summarized.
This document provides an overview of basic concepts in VB.NET, including variables, data types, constants, arrays, operators, flow control statements, and more. It defines variables as storage locations for values, and describes how to declare different data types like numeric, string, boolean, and object. Constants and enums are introduced as fixed values that cannot change. Arrays are defined as lists that allow storing multiple values of the same type. Common operators for arithmetic, comparison, logical operations and assignments are outlined. Decision making statements like If/Then and Select Case as well as looping constructs such as For, For Each, and Do loops are briefly explained.
The document discusses Java's primitive data types including their ranges and literal constants. It covers char, boolean, byte, short, int, long, float, and double data types. It also discusses variables, symbolic constants, and arithmetic operators.
Basic_C++ Notes with problema from Preethi arora and suneetha arora.pdfComputer Programmer
This document provides an overview of various fundamental concepts in problem solving and computer programming, including data types, operators, control flow statements, arrays, and functions. It describes the different types of data types like integer, floating point, character, boolean, derived, and user-defined types. It also explains various categories of operators like unary, binary, arithmetic, relational, logical, and bitwise operators. Additionally, it covers decision making statements, loops, jumping statements, and escape sequences to control program flow. The document also discusses arrays, pointers, functions, and classes.
The document discusses PHP concepts including:
- PHP is a server-side scripting language used for web development and can be used as an alternative to Microsoft ASP.
- XAMPP is an open-source cross-platform web server bundle that can be used to test PHP scripts locally.
- PHP has different data types including strings, integers, floats, booleans, and arrays.
- PHP includes various operators, conditional statements like if/else, and loops like while and foreach to control program flow.
- Functions allow code reusability and modularity in PHP programs. Built-in and user-defined functions are discussed.
- Arrays are a special variable type that can hold multiple values,
Chapter 01 Introduction to 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.
Variables are used to store information in programs and must have unique names. There are different data types that specify what type of value a variable can store, such as integer, float, double, character, and string. Variables are assigned values using the assignment operator (=), and variable names can be most anything but are typically descriptive. Comments are included in code to help explain it to other programmers.
The document defines various tokens in the C programming language including keywords, identifiers, constants, string literals, operators, data types, and variables. It discusses the basic data types like integers, floating point numbers, and characters. It also covers topics like declarations, global and local variables, type conversions, precedence and order of evaluation, and various operators used in C.
This document provides an overview and introduction to learning Python. It discusses Python programming concepts like data science, machine learning, data visualizations, and web development. It also outlines benefits of Python like job opportunities, large community, being cross-platform, and free. The document then describes the Anaconda distribution tool for scientific computing projects. It introduces the Spyder IDE and its features like source code area, IPython console, and variable/file explorers. Basic Python syntax is covered such as printing, strings, variables, and conditionals. Finally, it discusses lists, loops, and common list methods.
The document discusses pointers in C++. It defines a pointer as a variable that stores the memory address of another variable of the same data type. Pointers allow a program to indirectly access the memory location of another variable. The key points covered include:
- Declaring pointer variables using a data type followed by an asterisk (*)
- Initializing pointers using the address-of (&) operator to store the address of another variable
- Accessing the value at a pointer's address using the dereference (*) operator
- Pointer arithmetic, where pointers can be incremented or decremented to access subsequent memory addresses
- Dynamic memory allocation using new/delete to allocate memory at runtime through a pointer.
Java works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc.) I...GANESHBABUVelu
1. The document discusses various concepts in Java programming including data types, variables, operators, and decision making statements. It describes integer, floating point, character, and boolean data types.
2. It also covers variable declaration and scope, constants, arithmetic, relational, and logical operators. Decision making statements like if and switch statements are used for conditional branching in a program.
3. The document provides examples of declaring and assigning values to variables, using different types of operators to perform calculations and comparisons, and the syntax of if and switch statements.
This document provides an overview of C# data types, operators, expressions, statements, and other fundamental concepts. It discusses the different primitive data types in C#, including integer, floating-point, boolean, character, and string types. It also covers literals, variables, operators such as arithmetic, logical, comparison, and assignment, and shows examples of using each concept. The document is intended to teach basic C# syntax and semantics.
Implicit conversions and parameters allow interoperability between types in Scala. Implicit conversions define how one type can be converted to another type, and are governed by rules around marking, scope, ambiguity, and precedence. The compiler tries to insert implicit conversions in three places: to match an expected type, to convert a receiver before a method selection, and to provide missing implicit parameters. Debugging implicits involves explicitly writing out conversions to see where errors occur.
The document provides an overview of key concepts in the Java programming language including:
1. Java language fundamentals including building blocks like identifiers, literals, variables, and wrapper classes. Different types of literals like integral, floating point, character, string and boolean are described.
2. Control structures in Java including selection statements like if-else and switch statements, and iterative statements like while, do-while and for loops. Jump statements like break, continue and return are also covered.
3. Other concepts discussed include arrays, declaring and initializing array variables, and creating arrays using the new operator in Java.
The document provides an outline of topics for a C/C++ tutorial, including a "Hello World" program, data types, variables, operators, conditionals, loops, arrays, strings, functions, pointers, command-line arguments, data structures, and memory allocation. It gives examples and explanations of key concepts in C/C++ programming.
Let's explore some other fundamental programming concepts
Chapter 2 focuses on:
character strings
primitive data
the declaration and use of variables
expressions and operator precedence
data conversions
Similar to Dr. Rajeshree Khande : Programming concept of basic java (20)
How to Add Chatter in the odoo 17 ERP ModuleCeline George
In Odoo, the chatter is like a chat tool that helps you work together on records. You can leave notes and track things, making it easier to talk with your team and partners. Inside chatter, all communication history, activity, and changes will be displayed.
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...PECB
Denis is a dynamic and results-driven Chief Information Officer (CIO) with a distinguished career spanning information systems analysis and technical project management. With a proven track record of spearheading the design and delivery of cutting-edge Information Management solutions, he has consistently elevated business operations, streamlined reporting functions, and maximized process efficiency.
Certified as an ISO/IEC 27001: Information Security Management Systems (ISMS) Lead Implementer, Data Protection Officer, and Cyber Risks Analyst, Denis brings a heightened focus on data security, privacy, and cyber resilience to every endeavor.
His expertise extends across a diverse spectrum of reporting, database, and web development applications, underpinned by an exceptional grasp of data storage and virtualization technologies. His proficiency in application testing, database administration, and data cleansing ensures seamless execution of complex projects.
What sets Denis apart is his comprehensive understanding of Business and Systems Analysis technologies, honed through involvement in all phases of the Software Development Lifecycle (SDLC). From meticulous requirements gathering to precise analysis, innovative design, rigorous development, thorough testing, and successful implementation, he has consistently delivered exceptional results.
Throughout his career, he has taken on multifaceted roles, from leading technical project management teams to owning solutions that drive operational excellence. His conscientious and proactive approach is unwavering, whether he is working independently or collaboratively within a team. His ability to connect with colleagues on a personal level underscores his commitment to fostering a harmonious and productive workplace environment.
Date: May 29, 2024
Tags: Information Security, ISO/IEC 27001, ISO/IEC 42001, Artificial Intelligence, GDPR
-------------------------------------------------------------------------------
Find out more about ISO training and certification services
Training: ISO/IEC 27001 Information Security Management System - EN | PECB
ISO/IEC 42001 Artificial Intelligence Management System - EN | PECB
General Data Protection Regulation (GDPR) - Training Courses - EN | PECB
Webinars: https://pecb.com/webinars
Article: https://pecb.com/article
-------------------------------------------------------------------------------
For more information about PECB:
Website: https://pecb.com/
LinkedIn: https://www.linkedin.com/company/pecb/
Facebook: https://www.facebook.com/PECBInternational/
Slideshare: http://www.slideshare.net/PECBCERTIFICATION
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Dr. Vinod Kumar Kanvaria
Exploiting Artificial Intelligence for Empowering Researchers and Faculty,
International FDP on Fundamentals of Research in Social Sciences
at Integral University, Lucknow, 06.06.2024
By Dr. Vinod Kumar Kanvaria
Thinking of getting a dog? Be aware that breeds like Pit Bulls, Rottweilers, and German Shepherds can be loyal and dangerous. Proper training and socialization are crucial to preventing aggressive behaviors. Ensure safety by understanding their needs and always supervising interactions. Stay safe, and enjoy your furry friends!
A review of the growth of the Israel Genealogy Research Association Database Collection for the last 12 months. Our collection is now passed the 3 million mark and still growing. See which archives have contributed the most. See the different types of records we have, and which years have had records added. You can also see what we have for the future.
How to Manage Your Lost Opportunities in Odoo 17 CRMCeline George
Odoo 17 CRM allows us to track why we lose sales opportunities with "Lost Reasons." This helps analyze our sales process and identify areas for improvement. Here's how to configure lost reasons in Odoo 17 CRM
Main Java[All of the Base Concepts}.docxadhitya5119
This is part 1 of my Java Learning Journey. This Contains Custom methods, classes, constructors, packages, multithreading , try- catch block, finally block and more.
Executive Directors Chat Leveraging AI for Diversity, Equity, and InclusionTechSoup
Let’s explore the intersection of technology and equity in the final session of our DEI series. Discover how AI tools, like ChatGPT, can be used to support and enhance your nonprofit's DEI initiatives. Participants will gain insights into practical AI applications and get tips for leveraging technology to advance their DEI goals.
A Strategic Approach: GenAI in EducationPeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
Dr. Rajeshree Khande : Programming concept of basic java
1. Contents
1
Data types in Java
Strings & Characters
Arithmetic Operators & Expressions
Type Conversion
Comments
Arrays
Keywords
RAJESHREE KHANDE
2. Data Types, Variables, and
Constants
2
Declaring Variables
Primitive Data Types
Initial Values and Literals
String Literals and Escape Sequences
Constants
RAJESHREE KHANDE
3. Data Types
3
To declare a variable, assign a name (identifier) and a data type
Data type tells compiler:
How much memory to allocate
Format in which to store data
Types of operations you will perform on data
Compiler monitors use of data
Java is a "strongly typed" language
Java "primitive data types"
byte, short, int, long, float, double, char, boolean
RAJESHREE KHANDE
4. Declaring Variables
4
Variables hold one value at a time, but that value can change
Syntax:
dataType identifier;
or
dataType identifier1, identifier2, …;
Naming convention for variable names:
first letter is lowercase
embedded words begin with uppercase letter
RAJESHREE KHANDE
5. Integer Types - Whole Numbers
Example declarations:
int testGrade;
int numPlayers, highScore;
short xCoordinate, yCoordinate;
byte ageInYears;
long cityPopulation;
Type Size in
byte
Minimum Value Maximum Value
byte 1 -128 127
short 2 -32768 +32677
int 4 -2, 147, 483, 648 2, 147, 483, 647
long 8 -9,223,372,036,854,775,808 9,223,372,036,854,775,807
5RAJESHREE KHANDE
6. Floating-Point Data Types
Example declarations:
float salesTax;
double interestRate;
double paycheck,
sumSalaries;
Type Size in
byte
Minimum Value Maximum Value
Float 4 1.4E-45 3.4028235E38
Double 8 4.9E-324 1.7976931348623157E308
6RAJESHREE KHANDE
7. char Data Type
One Unicode character (16 bits - 2 bytes)
Type Size Minimum Value Maximum Value
in Bytes
char 2 character character
encoded as 0 encoded as
FFFF
Example declarations:
char finalGrade;
char newline, tab, doubleQuotes;
7RAJESHREE KHANDE
8. boolean Data Type
8
Two values only:
true
false
Used for decision making or controlling the order
of execution of a program
Example declarations:
boolean isEmpty;
boolean passed, failed;
RAJESHREE KHANDE
9. Assigning Values to Variables
9
Assignment operator =
Value on the right of the operator is assigned to the variable
on the left
Value on the right can be a literal (text representing a specific
value), another variable, or an expression (explained later)
Syntax:
dataType variableName = initialValue;
Or
dataType variable1 = initialValue1,
variable2 = initialValue2, …;
RAJESHREE KHANDE
10. Assigning the Values of Other
Variables
10
Syntax:
dataType variable2 = variable1;
Rules:
1. variable1 needs to be defined before this statement appears
in the source code
2. variable1 and variable2 need to be compatible data types; in
other words, the precision of variable1 must be lower than or
equal to that of variable2.
RAJESHREE KHANDE
11. Compatible Data Types
11
Any type in right column can be assigned to type in left
column:
Data Type Compatible Data Types
byte byte
short byte, short
int byte, short, int, char
long byte, short, int, long, char
float float, byte, short, int, long, char
double float, double, byte, short, int, long, char
boolean boolean
char char
RAJESHREE KHANDE
12. String Concatenation Operator (+)
12
Combines String literals with other data types for printing
Example:
String hello = "Hello";
String there = "there";
String greeting = hello + ' ' + there;
System.out.println( greeting );
Output is:
Hello there
RAJESHREE KHANDE
13. Escape Sequences
13
To include a special character in a String, use an
escape sequence
Character Escape Sequence
Newline n
Tab t
Double quotes "
Single quote '
Backslash
Backspace b
Carriage return r
Form feed f
See Example 2.3 Literals.java
RAJESHREE KHANDE
14. Assigning the Values of Other
Variables
14
Syntax:
dataType variable2 = variable1;
Rules:
1. variable1 needs to be defined before this statement appears
in the source code
2. variable1 and variable2 need to be compatible data types; in
other words, the precision of variable1 must be lower than or
equal to that of variable2.
RAJESHREE KHANDE
15. Sample Assignments
15
This is a valid assignment:
float salesTax = .05f;
double taxRate = salesTax;
This is invalid because the float data type is lower
in precision than the double data type:
double taxRate = .05;
float salesTax = taxRate;
RAJESHREE KHANDE
16. String Concatenation Operator (+)
16
Combines String literals with other data
types for printing
Example:
String hello = "Hello";
String there = "there";
String greeting = hello + ' ' + there;
System.out.println( greeting );
Output is:
Hello there
RAJESHREE KHANDE
17. Common Error Trap
17
String literals must start and end on the
same line. This statement:
System.out.println( "Never pass a water fountain
without taking a drink" );
generates these compiler errors:
unclosed string literal
')' expected
Break long Strings into shorter Strings and use
the concatenation operator:
System.out.println( "Never pass a water fountain"
+ " without taking a drink" );
RAJESHREE KHANDE
18. String Concatenation Operator (+)
18
Combines String literals with other data
types for printing
Example:
String hello = "Hello";
String there = "there";
String greeting = hello + ' ' + there;
System.out.println( greeting );
Output is:
Hello there
RAJESHREE KHANDE
19. Common Error Trap
19
String literals must start and end on the same line. This
statement:
System.out.println( "Never pass a water fountain
without taking a drink" );
generates these compiler errors:
unclosed string literal
')' expected
Break long Strings into shorter Strings and use the
concatenation operator:
System.out.println( "Never pass a water fountain"
+ " without taking a drink" );
RAJESHREE KHANDE
20. 20
Declare a variable only once
Once a variable is declared, its data type cannot
be changed.
These statements:
double twoCents;
double twoCents = .02;
generate this compiler error:
twoCents is already defined
RAJESHREE KHANDE
21. 21
Once a variable is declared, its data type cannot
be changed.
These statements:
double cashInHand;
int cashInHand;
generate this compiler error:
cashInHand is already defined
RAJESHREE KHANDE
22. Constants
22
Value cannot change during program execution
Syntax:
final dataType constantIdentifier =
assignedValue;
Note: assigning a value when the constant is
declared is optional. But a value must be
assigned before the constant is used.
RAJESHREE KHANDE
23. Mixed-Type Arithmetic
23
When performing calculations with operands of different
data types:
Lower-precision operands are promoted to higher-precision
data types, then the operation is performed
Promotion is effective only for expression evaluation;
not a permanent change
Called "implicit type casting“
Bottom line: any expression involving a floating-point operand
will have a floating-point result.
RAJESHREE KHANDE
24. Rules of Promotion
24
Applies the first of these rules that fits:
1. If either operand is a double, the other operand is converted
to a double
2. If either operand is a float, the other operand is converted to a
float.
3. If either operand is a long, the other operand is converted to a
long.
4. If either operand is an int, the other operand is promoted to an
int
5. If neither operand is a double, float, long, or an int, both
operands are promoted to int.
RAJESHREE KHANDE
25. Explicit Type Casting
25
Syntax:
(dataType)( expression )
Note: parentheses around expression are optional
if expression consists of 1 variable
Useful for calculating averages
RAJESHREE KHANDE
26. Operator Precedence
26
Operator Order of
evaluation
Operation
( ) left - right parenthesis for explicit grouping
++ -- right - left preincrement, predecrement
++ -- right - left postincrement, postdecrement
* / % left - right multiplication, division, modulus
+ - left - right addition or String concatenation,
subtraction
= += -= *=
/= %=
right - left assignment
RAJESHREE KHANDE
27. Variables and Assignments
27
Variables
Types
char 16 bits Unicode character data
boolean Boolean Variable
byte 8 bits signed integer
short 16 bits signed integer
int 32 bits signed integer
long 64 bits signed integer
float 32 bits signed floating point number
double 64 bits signed floating point number
RAJESHREE KHANDE
28. Strings and Characters
28
String : sequence of character
String s = “Enter an integer value: ” ;
Char c = ‘A’;
Concatenation Operator ‘+’
String s = “Lincoln said: ” + “” Four score and seven
years ago”” ;
Result :
Lincoln said: “Four score and seven years ago”
RAJESHREE KHANDE
29. Expression
29
char ch; int i; float f; double outcome;
ch = ‘0’; i = 10; f = 10.2f;
outcome = ch * i / f;
double
double float
float long
long int
Yes No
Yes No
Yes No
RAJESHREE KHANDE
30. Assignment
30
Widening Conversion
byte b = 127;
int i;
i = b;
Narrowing Conversion
byte b;
int i = 258;
b = (byte) i;
Wrong Conversion
byte b;
int i = 127;
b = i;
Right Conversion (But data may be lost)
byte b;
int i = 127;
b = (byte) i;
Type Casting
RAJESHREE KHANDE
31. Java Keywords
31
50 Java Keywords
abstract double int super
boolean else interface switch
break extends long synchronized
byte final native this
case finally new throw
catch float package throws
char for private transient*
class goto* protected try
const* if public void
continue implements return volatile
default import short while
do instanceof static strictfp
assert (New in 1.5) enum (New in 1.5)
The “assert” is recognized as keyword in JDK1.4 compiler, but we could not
use it.
It can be used it from 1.5.RAJESHREE KHANDE
32. Flow of Control
32
Java executes one statement after the other in the
order they are written
Many Java statements are flow control statements:
Alternation: if, if else, switch
Looping: for, while, do while
Escapes: break, continue, return
RAJESHREE KHANDE
34. If – The Conditional Statement
34
The if statement evaluates an expression and if that
evaluation is true then the specified action is taken
if ( x < 10 ) x = 10;
If the value of x is less than 10, make x equal to 10
It could have been written:
if ( x < 10 )
x = 10;
Or, alternatively:
if ( x < 10 )
{ x = 10; }
RAJESHREE KHANDE
35. If… else
35
The if … else statement evaluates an expression and
performs one action if that evaluation is true or a
different action if it is false.
if (x != oldx)
{
System.out.print(“x was changed”);
}
else {
System.out.print(“x is unchanged”);
}
RAJESHREE KHANDE
36. Nested if … else
36
if ( myVal > 100 ) {
if ( remainderOn == true) {
myVal = mVal % 100;
}
else {
myVal = myVal / 100.0;
}
}
else
{
System.out.print(“myVal is in range”);
}
RAJESHREE KHANDE
37. else if
37
Useful for choosing between alternatives:
if ( n == 1 ) {
// execute code block #1
}
else if ( j == 2 ) {
// execute code block #2
}
else {
// if all previous tests have failed, execute code
block #3
}
RAJESHREE KHANDE
38. The switch Statement
38
switch ( n ) {
case 1:
// execute code block #1
break;
case 2:
// execute code block #2
break;
default:
// if all previous tests fail then
//execute code block #4
break;
}
RAJESHREE KHANDE
39. The for loop
39
Loop n times
for ( i = 0; i < n; n++ )
{
// this code body will execute n times
// ifrom 0 to n-1
}
Nested for:
for ( j = 0; j < 10; j++ )
{
for ( i = 0; i < 20; i++ )
{
// this code body will execute 200 times
}
}
RAJESHREE KHANDE
41. do {… } while loops
41
do
{
System.out.print( “ID =” + userID[n] );
n++;
response = readInt( “Enter ” );
}while (response == 1);
RAJESHREE KHANDE
42. Break
42
A break statement causes an exit from the
innermost containing while, do, for or switch
statement.
for ( int i = 0; i < maxID, i++ )
{
if ( userID[i] == targetID )
{
index = i;
break;
}
} // program jumps here after break
RAJESHREE KHANDE
43. Continue
43
Can only be used with while, do or for.
The continue statement causes the innermost loop to start the
next iteration immediately.
for ( int i = 0; i < maxID; i++ )
{
if ( userID[i] != -1 )
continue;
System.out.print( “UserID ” + i + “ :” + userID)
}
RAJESHREE KHANDE
44. Arrays
44
Am array is a list of similar things
An array has a fixed:
name
type
length
These must be declared when the array is created.
Arrays sizes cannot be changed during the execution
of the code
RAJESHREE KHANDE
45. 45
myArray has room for 8 elements
The elements are accessed by their index
in Java, array indices start at 0
3 6 3 1 6 3 4 1myArray =
0 1 2 3 4 5 6 7
Arrays
RAJESHREE KHANDE
46. Declaring Arrays
46
int myArray[];
declares myArray to be an array of integers
myArray = new int[8];
sets up 8 integer-sized spaces in memory, labelled
myArray[0] to myArray[7]
int myArray[] = new int[8];
combines the two statements in one line
RAJESHREE KHANDE
47. Assigning Values
47
Refer to the array elements by index to store values in
them.
myArray[0] = 3;
myArray[1] = 6;
myArray[2] = 3; ...
Can create and initialise in one step:
int myArray[] = {3, 6, 3, 1, 6, 3, 4, 1};
RAJESHREE KHANDE
48. Iterating Through Arrays
48
for loops are useful when dealing with arrays:
for (int i = 0; i < myArray.length; i++)
{
myArray[i] = getsomevalue();
}
RAJESHREE KHANDE
49. Class & Object
49
What Are Classes?
A class is a blueprint or prototype that defines the
variables and the methods common to all objects of a
certain kind.
What Is an Object?
An object is a software bundle of variables and
related methods. Software objects are often used to
model real-world objects you find in everyday life.
RAJESHREE KHANDE
50. 50
Class vs. Object
Specifies the structure
(the number and types)
of its objects’ attributes
the same for all of its
objects
Specifies the possible
behaviors of its objects
Holds specific values of
attributes
These values can
change while the
program is running
Behaves appropriately
when called upon
RAJESHREE KHANDE
51. 51
Class vs. Object
A piece of the program’s
source code
Written by a
programmer
An entity in a running
program
Created when the
program is running (by
the main method or a
constructor)
RAJESHREE KHANDE
52. 52
Classes
public class Car
{
...
}
Car.java By convention, the
name of a class (and
its source file) always
starts with a capital
letter.
(In Java, all names are case-sensitive.)
RAJESHREE KHANDE
53. public class SomeClass
53
Fields
Constructors
Methods
}
Attributes / variables that define the
object’s state; can hold numbers,
characters, strings, other objects
Procedures for constructing a
new object of this class and
initializing its fields
Actions that an object of this
class can take (behaviors)
{
Class header
SomeClass.java
import ... import statements
RAJESHREE KHANDE
54. Classes
54
A class is a collection of fields (data) and methods
(procedure or function) that operate on that data.
The basic syntax for a class definition:
Bare bone class – no fields, no methods
public class Circle {
// my circle class
}
Class ClassName
{
[fields declaration]
[methods declaration]
}
RAJESHREE KHANDE
55. Classes
55
Classes describe the data held by each of its objects
A class may describe any number of objects
A class may describe a single object, or even no
objects at all.
RAJESHREE KHANDE
57. Adding Fields: Class Circle
with fields
57
Add fields
The fields (data) are also called the instance
varaibles.
public class Circle {
public double x, y; // centre coordinate
public double r; // radius of the circle
}
RAJESHREE KHANDE
58. Adding Methods
58
A class with only data fields has no life. Objects created
by such a class cannot respond to any messages.
Methods are declared inside the body of the class but
immediately after the declaration of data fields.
The general form of a method declaration is:
type MethodName (parameter-list)
{
Method-body;
}
RAJESHREE KHANDE
59. Adding Methods to Class
Circle
59
public class Circle {
public double x, y; // centre of the circle
public double r; // radius of circle
//Methods to return circumference and area
public double circumference() {
return 2*3.14*r;
}
public double area() {
return 3.14 * r * r;
}
}
public class Circle {
public double x, y; // centre of the circle
public double r; // radius of circle
//Methods to return circumference and area
public double circumference() {
return 2*3.14*r;
}
public double area() {
return 3.14 * r * r;
}
}
Method Body
RAJESHREE KHANDE
60. Data Abstraction &
Encapsulation
60
The wrapping of data & method in single unit called
class is known as encapsulation.
The data is not accessible to the outside world & only
those methods which wrapped inside the class can
access it.
These methods provide the interface between objects
data & program.
The insulation of data from direct access is called as
data hidingRAJESHREE KHANDE
61. Data Abstraction & Encapsulation
61
Abstraction refers to representing essential features
without including the background details.
Classes uses the concept of abstraction & are defined
as list of abstract attribute such as size ,weight & cost
and method that operate on theses data.
Declare the Circle class, have created a new data type
– Data Abstraction
Circle aCircle;
Circle bCircle;
RAJESHREE KHANDE
62. Class of Circle cont.
62
aCircle, bCircle simply refers to a Circle object, not
an object itself.
aCircle
Points to nothing (Null Reference)
bCircle
Points to nothing (Null Reference)
null null
RAJESHREE KHANDE
63. Creating objects of a class
63
Objects are created dynamically using the new
keyword.
aCircle and bCircle refer to Circle objects
bCircle = new Circle() ;aCircle = new Circle() ;
RAJESHREE KHANDE
64. 64
Creating objects of a class
aCircle = new Circle();
bCircle = new Circle() ;
bCircle = aCircle;
P
aCircle
Q
bCircle
Before Assignment
P
aCircle
Q
bCircle
Before Assignment
RAJESHREE KHANDE
65. Automatic garbage collection
65
The object does not have a reference and
cannot be used in future.
The object becomes a candidate for automatic garbage
collection.
Java automatically collects garbage periodically and
releases the memory used to be used in the future.
Q
RAJESHREE KHANDE
66. Accessing Object/Circle Data
66
Similar to C syntax for accessing data defined in a
structure.
Circle aCircle = new Circle();
aCircle.x = 2.0 // initialize center and radius
aCircle.y = 2.0
aCircle.r = 1.0
ObjectName.VariableName
ObjectName.MethodName(parameter-list)
RAJESHREE KHANDE
67. Executing Methods in Object/Circle
67
Using Object Methods:
Circle aCircle = new Circle();
double area1;
aCircle.r = 1.0;
area1 = aCircle.area();
sent ‘message’ to aCircle
RAJESHREE KHANDE
68. Using Circle Class
68
// Circle.java: Contains both Circle class and its user class
public class Circle
{
public double x, y; // centre of the circle
public double r; // radius of circle
//Methods to return circumference and area
public double circumference() {
return 2*3.14*r;
}
public double area() {
return 3.14 * r * r;
}
}
RAJESHREE KHANDE
69. Using Circle Class
69
class MyMain
{
public static void main(String args[])
{
Circle aCircle; // creating reference
aCircle = new Circle(); // creating object
aCircle.x = 10; // assigning value to data field
aCircle.y = 20;
aCircle.r = 5;
double area = aCircle.area(); // invoking method
System.out.println("Radius="+ aCircle.r+ " Area=“ + area);
}
} RAJESHREE KHANDE
70. Access Specifiers
70
In Java code, class and variable and method and
constructor declarations can have “access specifiers”
:
- private
- protected
- public.
- none (default)
The purpose of access specifiers is to declare which
entity can not be accessed from where.
RAJESHREE KHANDE
71. Access Specifiers for Class
Variables and Methods
71
Specifier class subclass package World
private Y
protected Y Y Y
public Y Y Y Y
none Y Y
RAJESHREE KHANDE
72. Protected
72
If a variable is declared protected, then the class
itself can access it.
Its subclass can access it
Any class in the same package can also access it.
RAJESHREE KHANDE
73. Public
73
Public classes, methods, and fields can be accessed from
everywhere.
The only constraint is that a file with Java source code can only
contain one public class whose name must also match with the
filename.
If it exists, this public class represents the application or the
applet, in which case the public keyword is necessary to enable
your Web browser or appletviewer to show the applet.
You use public classes, methods, or fields only if you explicitly
want to offer access to these entities.
public class Square
{ // public class public x, y, size; // public instance variables }
RAJESHREE KHANDE
74. Access Specifiers
74
None
If a class member doesn't have any access
specifier , then the class itself can access it.
Any class in the same package can also access it.
RAJESHREE KHANDE
75. Access Specifiers
75
class P
{
int x = 7;
}
public class AS
{
public static void main(String[] args)
{
P p = new P();
System.out.println(p.x);
}
}
The code compiles and
runs. But, if you add
“private” in front of “int x”,
then you'll get a compiler
error: “x has private
access in P”. This is
because when a
member variable is
private, it can only be
accessed within that
class
RAJESHREE KHANDE
76. Access Specifiers for Classes
76
For classes, only the “public” access specifier can be used.
Basically, Java has this “One Class Per File” paradigm.
That is, in every java source code file, only one class in the file is
public accessible, and that class must have the same name as
the file.
Optionally, the class can be declared with “public” keyword.
If you use any other access specifier on classes, or declare more
than one class “public” in a file, the compiler will give an error.
RAJESHREE KHANDE
77. Pass by value
77
Pass-by-value
The actual parameter (or argument expression) is fully
evaluated and the resulting value is copied into a location
being used to hold the formal parameter's value during
method/function execution.
That location is typically a chunk of memory on the runtime
stack for the application (which is how Java handles it), but
other languages could choose parameter storage differently.
Pass-by-reference
The formal parameter merely acts as an alias for the actual
parameter. Anytime the method/function uses the formal
parameter (for reading or writing), it is actually using the actual
parameter.
Java is strictly pass-by-value,
RAJESHREE KHANDE
78. Pass by value
78
In Java, Objects are passed by reference, and
primitives are passed by value.
This is half incorrect. Everyone can easily agree that
primitives are passed by value; there's no such thing
in Java as a pointer/reference to a primitive.
However, Objects are not passed by reference. A
correct statement would be Object references are
passed by value.
RAJESHREE KHANDE
79. this keyword
79
Sometimes a method will need to refer to the object
that invoked it.
To allow this, Java defines the this keyword.
this can be used inside any method to refer to the
current object.
That is, this is always a reference to the object on
which the method was invoked.
RAJESHREE KHANDE
80. this keyword
80
'this' is used for pointing the current class instance.
It can be used with variables or methods. Look into
the following example:
class Test
{ private int i=10;
public void m()
{ System.out.println(this.i);
}
}
RAJESHREE KHANDE
81. this keyword
81
this keyword is useful when we use same name
for parameter and instance variable
In the above code this is used for the current
instance.
Since this is instance of a class it cannot be used
inside a static method.
RAJESHREE KHANDE
82. this : Example
82
class Cat
{
int height weight;
public accept( int height, int weight)
{
this.height = height;
this.weight =weight;
}
}
RAJESHREE KHANDE
83. Static variable & Static Method
83
Like instance variable, static variable is declare inside
a class but outside any method.
Keyword static is used while declaring static variable.
Syntax
static int count;
static int max(int x, int y);
Static variable
Static method
RAJESHREE KHANDE
84. Static variable & Static Method
84
The static variable & static method belong to class
rather than object these variables is also called as
class variable and class method.
Static variable is defined when we have a variable
common to all instance of class.
These member are accessed with class name.
Syntax:
classname.staticVariableName;
classname.staticMethodName();
RAJESHREE KHANDE