The document provides an overview of core Java basics including data types, operators, keywords, comments, literals, type conversion and casting, classes and objects, constructors, class variables, constants, and static methods. It discusses primitive data types like int, float, boolean and their ranges. It also covers operators precedence and arithmetic, logical, and assignment operators.
This the slide stack for the two videos on Data types in my YouTube series on JavaScript. The videos are at https://www.youtube.com/watch?v=UAtJXkGggOU and https://www.youtube.com/watch?v=H2sjsGZyYaw
03 and 04 .Operators, Expressions, working with the console and conditional s...Intro C# Book
In this chapter we will get acquainted with the operators in Java and the actions they can perform on the different data types. We will explain the priorities of the operators and we will analyze the different types of operators, according to the count of the arguments they can take and the actions they can perform. In the second part we will examine the conversion of data types.
This the slide stack for the two videos on Data types in my YouTube series on JavaScript. The videos are at https://www.youtube.com/watch?v=UAtJXkGggOU and https://www.youtube.com/watch?v=H2sjsGZyYaw
03 and 04 .Operators, Expressions, working with the console and conditional s...Intro C# Book
In this chapter we will get acquainted with the operators in Java and the actions they can perform on the different data types. We will explain the priorities of the operators and we will analyze the different types of operators, according to the count of the arguments they can take and the actions they can perform. In the second part we will examine the conversion of data types.
45 Days C++ Programming Language Training in Ambalajatin batra
Are you looking for C++Programming Training In Ambala?
Now you search ends here... Batra Computer Centre provides you best C++ Programming Language Training in Ambala Cantt. We also proides you training in C, HTML, PHP, Web Designing, Web Development, SEO, SMO also.
Implicit conversions and implicit parameters are fundamental and unique features of Scala that are powerful at the same time. To use these features to their maximum potential, and do so with confidence, you have to understand the specifics of how Scala compiler’s implicits search works. I will cover this topic in details, including ways you can optimize the implicits search algorithm in your library.
The second part of my session will focus on IntelliJ IDEA and how to leverage your IDE for working with implicits. Among other helpful IDE features, I will show how to debug implicits in IntelliJ IDEA.
As examples we’ll take a look at a few Scala libraries, including Spray with its well-known Magnet pattern.
On top of that, during my talk I’ll show you a few new tips and tricks on how to be more efficient by using IntelliJ IDEA’s hidden gems when working with Scala. "
Dr archana dhawan bajaj's Sales JetView.Dr archana dhawan bajaj is a renowned practising doctor of non-commercial of India and Dr archana various Hospitals and Meternity.Dr archana dhawan bajaj has a PH.d master's degree in both human & International client Management along with other fellow.Dr archana is known to be proficient in Hindi,English,Sanskrit and Urdu.Dr archana dhawan bajaj has acquired extensive practice experience in maternity primarily in relation to corporate and international matter delivery.Dr archana dhawan bajaj's Sales JetView.Dr archana dhawan bajaj is a renowned practising doctor of non-commercial of India and Dr archana various Hospitals and Meternity.Dr archana dhawan bajaj has a PH.d master's degree in both human & International client Management along with other fellow.Dr archana is known to be proficient in Hindi,English,Sanskrit and Urdu.Dr archana dhawan bajaj has acquired extensive practice experience in maternity primarily in relation to corporate and international matter delivery.Dr archana dhawan bajaj's Sales JetView.Dr archana dhawan bajaj is a renowned practising doctor of non-commercial of India and Dr archana various Hospitals and Meternity.Dr archana dhawan bajaj has a PH.d master's degree in both human & International client Management along with other fellow.Dr archana is known to be proficient in Hindi,English,Sanskrit and Urdu.Dr archana dhawan bajaj has acquired extensive practice experience in maternity primarily in relation to corporate and international matter delivery.Dr archana dhawan bajaj's Sales JetView.Dr archana dhawan bajaj is a renowned practising doctor of non-commercial of India and Dr archana various Hospitals and Meternity.Dr archana dhawan bajaj has a PH.d master's degree in both human & International client Management along with other fellow.Dr archana is known to be proficient in Hindi,English,Sanskrit and Urdu.Dr archana dhawan bajaj has acquired extensive practice experience in maternity primarily in relation to corporate and international matter delivery.Dr archana dhawan bajaj's Sales JetView.Dr archana dhawan bajaj is a renowned practising doctor of non-commercial of India and Dr archana various Hospitals and Meternity.Dr archana dhawan bajaj has a PH.d master's degree in both human & International client Management along with other fellow.Dr archana is known to be proficient in Hindi,English,Sanskrit and Urdu.Dr archana dhawan bajaj has acquired extensive practice experience in maternity primarily in relation to corporate and international matter delivery.Dr archana dhawan bajaj's Sales JetView.Dr archana dhawan bajaj is a renowned practising doctor of non-commercial of India and Dr archana various Hospitals and Meternity.Dr archana dhawan bajaj has a PH.d master's degree in both human & International client Management along with other fellow.Dr archana is known to be proficient in Hindi,English,Sanskrit and Urdu.Dr archana dhawan bajaj has acquired extensive practice exp
This presentation is ideal for a beginner of Java or someone who wants to brush up their Java Knowledge. It's simple to understand and well organized in a way most of the area in core Java has been covered.
45 Days C++ Programming Language Training in Ambalajatin batra
Are you looking for C++Programming Training In Ambala?
Now you search ends here... Batra Computer Centre provides you best C++ Programming Language Training in Ambala Cantt. We also proides you training in C, HTML, PHP, Web Designing, Web Development, SEO, SMO also.
Implicit conversions and implicit parameters are fundamental and unique features of Scala that are powerful at the same time. To use these features to their maximum potential, and do so with confidence, you have to understand the specifics of how Scala compiler’s implicits search works. I will cover this topic in details, including ways you can optimize the implicits search algorithm in your library.
The second part of my session will focus on IntelliJ IDEA and how to leverage your IDE for working with implicits. Among other helpful IDE features, I will show how to debug implicits in IntelliJ IDEA.
As examples we’ll take a look at a few Scala libraries, including Spray with its well-known Magnet pattern.
On top of that, during my talk I’ll show you a few new tips and tricks on how to be more efficient by using IntelliJ IDEA’s hidden gems when working with Scala. "
Dr archana dhawan bajaj's Sales JetView.Dr archana dhawan bajaj is a renowned practising doctor of non-commercial of India and Dr archana various Hospitals and Meternity.Dr archana dhawan bajaj has a PH.d master's degree in both human & International client Management along with other fellow.Dr archana is known to be proficient in Hindi,English,Sanskrit and Urdu.Dr archana dhawan bajaj has acquired extensive practice experience in maternity primarily in relation to corporate and international matter delivery.Dr archana dhawan bajaj's Sales JetView.Dr archana dhawan bajaj is a renowned practising doctor of non-commercial of India and Dr archana various Hospitals and Meternity.Dr archana dhawan bajaj has a PH.d master's degree in both human & International client Management along with other fellow.Dr archana is known to be proficient in Hindi,English,Sanskrit and Urdu.Dr archana dhawan bajaj has acquired extensive practice experience in maternity primarily in relation to corporate and international matter delivery.Dr archana dhawan bajaj's Sales JetView.Dr archana dhawan bajaj is a renowned practising doctor of non-commercial of India and Dr archana various Hospitals and Meternity.Dr archana dhawan bajaj has a PH.d master's degree in both human & International client Management along with other fellow.Dr archana is known to be proficient in Hindi,English,Sanskrit and Urdu.Dr archana dhawan bajaj has acquired extensive practice experience in maternity primarily in relation to corporate and international matter delivery.Dr archana dhawan bajaj's Sales JetView.Dr archana dhawan bajaj is a renowned practising doctor of non-commercial of India and Dr archana various Hospitals and Meternity.Dr archana dhawan bajaj has a PH.d master's degree in both human & International client Management along with other fellow.Dr archana is known to be proficient in Hindi,English,Sanskrit and Urdu.Dr archana dhawan bajaj has acquired extensive practice experience in maternity primarily in relation to corporate and international matter delivery.Dr archana dhawan bajaj's Sales JetView.Dr archana dhawan bajaj is a renowned practising doctor of non-commercial of India and Dr archana various Hospitals and Meternity.Dr archana dhawan bajaj has a PH.d master's degree in both human & International client Management along with other fellow.Dr archana is known to be proficient in Hindi,English,Sanskrit and Urdu.Dr archana dhawan bajaj has acquired extensive practice experience in maternity primarily in relation to corporate and international matter delivery.Dr archana dhawan bajaj's Sales JetView.Dr archana dhawan bajaj is a renowned practising doctor of non-commercial of India and Dr archana various Hospitals and Meternity.Dr archana dhawan bajaj has a PH.d master's degree in both human & International client Management along with other fellow.Dr archana is known to be proficient in Hindi,English,Sanskrit and Urdu.Dr archana dhawan bajaj has acquired extensive practice exp
This presentation is ideal for a beginner of Java or someone who wants to brush up their Java Knowledge. It's simple to understand and well organized in a way most of the area in core Java has been covered.
here are some slides for introduction to C++. this slide is merely for basic understanding for C++. this powerpoint is written in Traditional Chinese(TW) and is owned by a group named "Awakening Lion" which I participate in.
Lecture 3 from the IAG0040 Java course in TTÜ.
See the accompanying source code written during the lectures: https://github.com/angryziber/java-course
Discusses more Java basics and Object Oriented Programming.
Vibrant Technologies is headquarted in Mumbai,India.We are the best Java training provider in Navi Mumbai who provides Live Projects to students.We provide Corporate Training also.We are Best Java classes in Mumbai according to our students and corporators
Contact Us On : http://vibranttechnologies.co.in/
Removing Uninteresting Bytes in Software FuzzingAftab Hussain
Imagine a world where software fuzzing, the process of mutating bytes in test seeds to uncover hidden and erroneous program behaviors, becomes faster and more effective. A lot depends on the initial seeds, which can significantly dictate the trajectory of a fuzzing campaign, particularly in terms of how long it takes to uncover interesting behaviour in your code. We introduce DIAR, a technique designed to speedup fuzzing campaigns by pinpointing and eliminating those uninteresting bytes in the seeds. Picture this: instead of wasting valuable resources on meaningless mutations in large, bloated seeds, DIAR removes the unnecessary bytes, streamlining the entire process.
In this work, we equipped AFL, a popular fuzzer, with DIAR and examined two critical Linux libraries -- Libxml's xmllint, a tool for parsing xml documents, and Binutil's readelf, an essential debugging and security analysis command-line tool used to display detailed information about ELF (Executable and Linkable Format). Our preliminary results show that AFL+DIAR does not only discover new paths more quickly but also achieves higher coverage overall. This work thus showcases how starting with lean and optimized seeds can lead to faster, more comprehensive fuzzing campaigns -- and DIAR helps you find such seeds.
- These are slides of the talk given at IEEE International Conference on Software Testing Verification and Validation Workshop, ICSTW 2022.
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Albert Hoitingh
In this session I delve into the encryption technology used in Microsoft 365 and Microsoft Purview. Including the concepts of Customer Key and Double Key Encryption.
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofsAlex Pruden
This paper presents Reef, a system for generating publicly verifiable succinct non-interactive zero-knowledge proofs that a committed document matches or does not match a regular expression. We describe applications such as proving the strength of passwords, the provenance of email despite redactions, the validity of oblivious DNS queries, and the existence of mutations in DNA. Reef supports the Perl Compatible Regular Expression syntax, including wildcards, alternation, ranges, capture groups, Kleene star, negations, and lookarounds. Reef introduces a new type of automata, Skipping Alternating Finite Automata (SAFA), that skips irrelevant parts of a document when producing proofs without undermining soundness, and instantiates SAFA with a lookup argument. Our experimental evaluation confirms that Reef can generate proofs for documents with 32M characters; the proofs are small and cheap to verify (under a second).
Paper: https://eprint.iacr.org/2023/1886
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfPaige Cruz
Monitoring and observability aren’t traditionally found in software curriculums and many of us cobble this knowledge together from whatever vendor or ecosystem we were first introduced to and whatever is a part of your current company’s observability stack.
While the dev and ops silo continues to crumble….many organizations still relegate monitoring & observability as the purview of ops, infra and SRE teams. This is a mistake - achieving a highly observable system requires collaboration up and down the stack.
I, a former op, would like to extend an invitation to all application developers to join the observability party will share these foundational concepts to build on:
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfPeter Spielvogel
Building better applications for business users with SAP Fiori.
• What is SAP Fiori and why it matters to you
• How a better user experience drives measurable business benefits
• How to get started with SAP Fiori today
• How SAP Fiori elements accelerates application development
• How SAP Build Code includes SAP Fiori tools and other generative artificial intelligence capabilities
• How SAP Fiori paves the way for using AI in SAP apps
Essentials of Automations: The Art of Triggers and Actions in FMESafe Software
In this second installment of our Essentials of Automations webinar series, we’ll explore the landscape of triggers and actions, guiding you through the nuances of authoring and adapting workspaces for seamless automations. Gain an understanding of the full spectrum of triggers and actions available in FME, empowering you to enhance your workspaces for efficient automation.
We’ll kick things off by showcasing the most commonly used event-based triggers, introducing you to various automation workflows like manual triggers, schedules, directory watchers, and more. Plus, see how these elements play out in real scenarios.
Whether you’re tweaking your current setup or building from the ground up, this session will arm you with the tools and insights needed to transform your FME usage into a powerhouse of productivity. Join us to discover effective strategies that simplify complex processes, enhancing your productivity and transforming your data management practices with FME. Let’s turn complexity into clarity and make your workspaces work wonders!
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
Climate Impact of Software Testing at Nordic Testing DaysKari Kakkonen
My slides at Nordic Testing Days 6.6.2024
Climate impact / sustainability of software testing discussed on the talk. ICT and testing must carry their part of global responsibility to help with the climat warming. We can minimize the carbon footprint but we can also have a carbon handprint, a positive impact on the climate. Quality characteristics can be added with sustainability, and then measured continuously. Test environments can be used less, and in smaller scale and on demand. Test techniques can be used in optimizing or minimizing number of tests. Test automation can be used to speed up testing.
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
A tale of scale & speed: How the US Navy is enabling software delivery from l...sonjaschweigert1
Rapid and secure feature delivery is a goal across every application team and every branch of the DoD. The Navy’s DevSecOps platform, Party Barge, has achieved:
- Reduction in onboarding time from 5 weeks to 1 day
- Improved developer experience and productivity through actionable findings and reduction of false positives
- Maintenance of superior security standards and inherent policy enforcement with Authorization to Operate (ATO)
Development teams can ship efficiently and ensure applications are cyber ready for Navy Authorizing Officials (AOs). In this webinar, Sigma Defense and Anchore will give attendees a look behind the scenes and demo secure pipeline automation and security artifacts that speed up application ATO and time to production.
We will cover:
- How to remove silos in DevSecOps
- How to build efficient development pipeline roles and component templates
- How to deliver security artifacts that matter for ATO’s (SBOMs, vulnerability reports, and policy evidence)
- How to streamline operations with automated policy checks on container images
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
3. Data Types
Primitive Types
Type Representation Range
byte 8-bit, signed -128 to 127
short 16-bit, signed -32768 to 32767
int 32-bit, signed -2147483648 to 2147483647
long 64-bit, signed -9223372036854775808 to
9223372036854775807
char 16-bit, unsigned, Unicode
float 32-bit 1.40239846e-45 to 3.40282347e+38
double 64-bit 4.94065645841246544e-324 to
1.79769313486231570e+308
boolean
4. Java Operators
Precedence Operator Description
1 ++, -- Increment and decrement
1 +, - Unary plus and minus
1 ~ Bitwise complement
1 ! Boolean
2 *, /, % Multiplication, division, remainder
3 +, - Addition and subtraction
3 + String
4 << Left shift
4 >> Right shift with sign extension
4 >>> Right shift with no extension
5. 5 <, <=, >, >= Numeric comparison
5 instanceof Type comparison
6 ==, != Equality and inequality of value
6 ==, != Equality and inequality of reference
7 & Bitwise AND
8 ^ Bitwise XOR
9 | Bitwise OR
10 && Conditional AND
11 || Conditional OR
12 ?: Conditional ternary operator
13 = *=, /=, %=, +=, -=, <<=, >>=, >>>=, &=, ^=, |=
Assignment
6. Keywords
abstract default goto null synchronized
boolean do if package this
break double implements private throw
byte else import protected throws
case extends instanceof public transient
catch false int return true
char final interface short try
class finally long static void
const float native super volatile
continue for new switch while
7. Comments
Java supports three styles of comments:
•A standard C-style comment, where all of the characters between
/* and */ are ignored.
•A single-line comment, where all of the characters from
// to the end of the line are ignored.
•A documentation comment that begins with
/** and ends with */.
8. Literals
Integer literals
Integer literals can be specified in octal (base 8), decimal (base 10), or
hexadecimal (base 16).
int i = 1230;
int i = 01230; // i = 664 decimal
int i = 0xFFFF;
Floating-point literals
Floating-point literals are of type double unless they are suffixed
with an f denoting that they are to be produced as a float value:
double d = 8.31;
double e = 3.00e+8;
float f = 8.31F; float g = 3.00e+8F;
9. Character literals
A literal character value can be specified either as a single-quoted
character or as an escaped ASCII or Unicode sequence:
char a = 'a';
char newline = 'n';
char ch = 88 ; //code for X
Boolean Literals
It can have only one of two possible values, true or false
boolean b = false;
10. Type Conversion and Casting
When one type of data is assigned to another type of variable, an
automatic type conversion will take place if
• The two types are compatible
• The destination type is larger than the source type.
Casting Incompatible Types
To create a conversion between two incompatible types, you must
use a cast.
(target-type) value;
11. Casting
1) int a;
a = 10;
byte b;
b = (byte) a;
2) byte b;
int i = 257;
b = (byte) i; // 1
3) double d = 223.22;
int i = (int) d; // 223
12. Automatic Type Promotion in Expressions
Java automatically promotes each byte type or short operand to int
when evaluating an expression.
byte b= 50;
b = b * 2; // Error. Cannot assign an int to a byte
b = (byte) (b*2); // valid
13. Array Creation and Initialization
As in C, array indices start with zero.
After creation, the array elements are initialized to the default values for
their type.
For numeric types, this means the elements are initially zero:
int [] grades = new int [30];
grades[0] = 99;
grades[1] = 72;
Java supports the C-style curly braces {} construct for creating an
array and initializing its elements when it is declared:
int [] primes = { 1, 2, 3, 5, 7, 7+4 };
An array object of the proper type and length is
implicitly created.
14. Comparing C++ and Java
The important features that distinguish Java from C++.
1. The biggest potential stumbling block is speed: interpreted Java runs
in the range of 20 times slower than C.
2. Everything must be in a class. There are no global functions or global
data. If you want the equivalent of globals, make static methods
and static data within a class.
3. There are no structs or enumerations or unions, only classes.
4. All method definitions are defined in the body of the class. Thus, in
C++ it would look like all the functions are inlined, but they’re not.
5. Class definitions are roughly the same form in Java as in C++, but
there’s no closing semicolon. There are no class declarations of the
form class foo; , only class definitions.
15. 6. There’s no scope resolution operator :: in Java.
7. In addition, package names are established using the dot, and to
perform a kind of C++ #include you use the import keyword.
For example: import java.awt.*;.
8. Java, like C++, has primitive types for efficient access. All the
primitive types have specified sizes that are machine independent for
portability.
9. Type-checking and type requirements are much tighter in Java.
For example:
1. Conditional expressions can be only boolean, not integral.
2. The result of an expression like X + Y must be used;
10. The char type uses the international 16-bit Unicode character set, so
it can automatically represent most national characters.
16. 11. Static quoted strings are automatically converted into String
objects. There is no independent static character array string like there is
in C and C++.
12. Java adds the triple right shift >>> to act as a “logical” right shift by
inserting zeroes at the top end;
13. Although they look similar, arrays have a very different structure and
behavior in Java than they do in C++. There’s a read-only length
member that tells you how big the array is, and run-time checking throws
an exception if you go out of bounds.
All arrays are created on the heap, and you can assign one array to
another (the array handle is
simply copied). The array identifier is a an object
14. All objects of non-primitive types can be created only via new.
There’s no equivalent to creating non-primitive objects “on the stack” as
in C++.
17. 15. All primitive types can be created only on the stack, without new.
There are wrapper classes for all primitive classes so that you can create
equivalent heap-based objects via new.
17. Java has no preprocessor. There are no preprocessor-like macros.
18. Initialization of class data members is guaranteed in Java; if you
don’t explicitly initialize them they get a default value (a zero or
equivalent). You can initialize them explicitly, either when you define
them in the class or in the constructor.
19. There are no Java pointers in the sense of C and C++.
20. There are no destructors in Java. The lifetime of an object is
determined instead by the garbage collector.
There is a finalize( ) method that’s a member of each class, something
like a C++ destructor, but finalize( ) is called by the garbage collector
and is supposed to be responsible only for releasing "resources" (such as
open files, sockets, ports, URLs, etc).
18. 21. Java does not support default arguments.
22. Java uses a singly-rooted hierarchy, so all objects are ultimately
inherited from the root class Object.
In C++, you can start a new inheritance tree anywhere, so you end up
with a forest of trees. In Java you get a single ultimate hierarchy.
23. Garbage collection means memory leaks are much harder to cause in
Java, but not impossible.
24. No inline methods. The Java compiler might decide on its own to
inline a method, but you don’t have much control over this. You can
suggest inlining in Java by using the final keyword for a method.
25. Java has method overloading, but no operator overloading.
19. Generally, Java is more robust, via:
– Object handles initialized to null (a keyword)
– Handles are always checked and exceptions are thrown for failures
– All array accesses are checked for bounds violations
– Automatic garbage collection prevents memory leaks
– Clean, relatively fool-proof exception handling
– Simple language support for multithreading
– Bytecode verification of network applets
20. HelloWorld.java
public class HelloWorld
{ public static void main(String[] args)
{
System.out.println("Hello World!");
}
}
C:> javac HelloWorld.java
//produces the HelloWorld.class
C:> java HelloWorld //when you invoke the
interpreter, you do not supply the .class extension
21. System class has several fields, and if you select
out you’ll discover that it’s a static PrintStream object.
Since it’s static you don’t need to create anything.
The out object is always there and you can just use it.
println( ), method prints to the console and end with a new line.
22. class P
{
public static void main(String args[])
{ int x =34;
int y =42;
System.out.println("X = " + x);
System.out.println("y = " + y);
int z = x+y;
System.out.println("z = " + z);
}
}
All local variables has to be initialized before using.
24. The Left Shift operator
int i;
byte a = 256,b;
i = a<< 2;
b = (byte) (a<<2);
System.out.println(“ i and b : “ + i + “ “ + b);
// i and b : 256 and 0
a is promoted to int for the purpose of evaluation, left shifting the value
64 twice results in I containing the value 256
0100 0000
0000 0001 0000 0000
25. The Right Shift operator
int a =32 ;
a = a >> 1; // a now contains 16
int x = 35;
x = x >> 2; // x contains 8
0010 0011 35
>>2
0000 1000 8
---------------------------------------------------
11111000 -8
>>1
11111100 -4
26. The Unsigned Right Shift operator
>>> shifts zero’s into the high-order bit.
int a = -1 ;
a = a >>> 24;
11111111 11111111 11111111 11111111 // -1 in binary
>>> 24
00000000 00000000 00000000 11111111 // 255 in binary
27. Boolean Logical Operators
& Logical AND
| Logical OR
^ Logical XOR
&& Short- Circuit Logical AND
|| Short- Circuit Logical OR
If you use the || and && forms rather than | and & forms , Java
will not bother to evaluate the right hand operand when the outcome of
the expression can be determined by the left operand alone.
if( denom != 0 && num /denom >10) // if denom =0 short circuit
if( c = =1 & e++ <100) d= 100;
Single & ensures that the increment operation will be applied whether c
is equal to 1 or not.
28. Classes and Objects
A Class is a template for an object,
And an object is an instance of a class.
These characteristics represent a pure approach to object-oriented
programming:
1. Everything is an object.
2. A program is a bunch of objects telling each other
what to do by sending messages.
3. All objects of a particular type can receive the same
messages.
4. Tight Cohesion within an object and Loose coupling
among objects.
29. The Class of Circles
public class Circle
{
public double x, y; // The coordinates of the center
public double r; // The radius
// Method that returns the area of the circle
public double area( )
{
return 3.14159 * r*r;
}
}
30. Objects Are Instances of a Class
We can declare variables of that type:
Circle c;
But this variable c is simply a name that refers to a circle object; it
is not an object itself.
In Java, all objects must be created dynamically. This is almost
always done with the new keyword:
c = new Circle();
Now we have created an instance of our Circle class--a circle
object--and have assigned it to the variable c, which is of type
Circle.
Accessing Object Data
c.x = 2.0; // Initialize our circle to have center (2, 2) and radius 1.0.
c.y = 2.0; c.r = 1.0;
31. Using Object Methods
double a;
a = c.area();
How can a method that takes no arguments know what
data to operate on?
In fact, the area() method does have an argument!
area() is implemented with an implicit argument that is not
shown in the method declaration.
The implicit argument is named this, and refers to "this
object"-- the Circle object through which the method is
invoked.
The implicit this argument is not shown in method
signatures.
We can use the this keyword explicitly.
32. Constructor
public class Circle
{
public double x, y, r; // The center and the radius of the circle
// The constructor method.
public Circle(double x, double y, double r)
{ this.x = x; this.y = y; this.r = r; } …………
With this new constructor the initialization becomes part of the
object creation step:
Circle c = new Circle(1.414, -1.0,1 .25);
There are two important notes about naming and declaring
constructors:
•The constructor name is always the same as the class name.
33. Multiple Circle Constructors
public class Circle {
public double x, y, r;
// Initializing constructors
public Circle(double x, double y, double r)
{ this.x = x; this.y = y; this.r = r; }
public Circle(double r) { x = 0.0; y = 0.0; this.r = r; }
// Copy Constructor
public Circle(Circle c) { x = c.x; y = c.y; r = c.r; }
//Default Constructor
public Circle() { x = 0.0; y = 0.0; r = 1.0; }
34. this Again
There is a specialized use of the this keyword that arises when a class
has multiple constructors
--it can be used from a constructor to invoke one of the other
constructors of the same class.
public Circle(double x, double y, double r)
{ this.x = x; this.y = y; this.r = r; }
public Circle(double r) { this(0.0, 0.0, r); }
public Circle(Circle c) { this(c.x, c.y, c.r); }
public Circle() { this(0.0, 0.0, 1.0); }
This would be a more impressive example, of course, if the first
constructor that we were invoking did a more significant amount of
initialization.
35. Class Variables
Java uses the static keyword to indicate that a particular variable is a
class variable rather than an instance variable.
That is, that there is only one copy of the variable, associated with the
class, rather than many copies of the variable associated with each
instance of the class.
The one copy of the variable exists regardless of the number of instances
of the class that are created--it exists and can be used even if the class is
never actually instantiated.
Static Variable Example
public class Circle
{ static int num_circles = 0; // class variable: how many circles
created public double x, y, r; // instance vars: the center and
the radius
public Circle(double x, double y, double r)
36. Accessing Class Variables
Because static variables are associated with the class rather than with an
instance, we access them through the class rather than through the
instance
System.out.println("Number of circles created: " +
Circle.num_circles);
37. Constants: Another Class Variable Example
When computing the area and circumference of circles, we use the value
pi. Since we use the value frequently, we don't want to keep typing
out 3.14159, so we'll define it as a class variable that has a convenient
name:
public class Circle
{
public static final double PI = 3.14159;
public double x, y, r;
// ... etc....
}
Besides the static keyword that we've already seen, we use the final
keyword, which means that this variable can never have its value
changed.
38. static Methods
Class methods are like class variables in a number of ways:
•Class methods are declared with the static keyword.
•Class methods are invoked through the class rather than
through an instance.
•Class methods are the closest Java comes to "global"
methods. Because they must be referred to by the class
name, there is no danger of name conflicts.
•Class methods differ from instance methods in one
important way: they are not passed an implicit this
reference.
39. A Class Method and an Instance Method
public class Circle
{ public double x, y, r;
// An instance method. Returns the bigger of two circles.
public Circle bigger(Circle c)
{ if (c.r > r) return c;
else return this;
}
// A class method. Returns the bigger of two circles.
public static Circle bigger(Circle a, Circle b)
{ if (a.r > b.r) return a;
else return b;
}
40. . . // Other methods omitted here. . }
You would invoke the instance method like this:
Circle a = new Circle(2.0);
Circle b = new Circle(3.0);
Circle c = a.bigger(b); // or, b.bigger(a);
And you would invoke the class method like this:
Circle c = Circle.bigger(a,b);
41. Object Destruction
How do you destroy objects when they are no longer needed?
The answer is: You don't!
Garbage Collection
The technique Java uses to get rid of objects once they are no longer
needed is called garbage collection.
The Java interpreter knows what objects it has allocated.
It can figure out when an allocated object is no longer referred to by any
other object or variable. When it finds such an object, it knows that it can
destroy it safely, and does so.
The Java garbage collector runs as a low-priority thread, and does most
of its work when nothing else is going on.
The only time the garbage collector must run while something high-
priority is going on is when the interpreter has run out of memory.
42. Object Finalization
Just as a constructor method performs initialization for an
object, a Java finalizer method performs finalization for an
object.
Garbage collection automatically frees up the memory
resources used by objects.
But objects may hold other kinds of resources, such as file
descriptors or sockets, as well.
The garbage collector can't free these resources up for you, so
you should write a finalizer method that takes care of things
like closing open files, terminating network connections, and
so on.
43. A finalizer is an instance method (i.e., non-static),
takes no arguments, returns no value (i.e., void), and must be
named finalize().
Ex:
protected void finalize() throws IOException
{
……
}
44. There are some additional things to be aware of about
finalizers:
•If an object has a finalizer, that method is invoked before
the system garbage collects the object.
•The Java interpreter may exit without garbage collecting
all outstanding objects, so some finalizers may never be
invoked. In this case, though, any outstanding resources are
usually freed by the operating system.
•Java makes no guarantees about when garbage collection
will occur, or what order objects will be collected in.
45. Java access specifiers
The Java access specifiers public, protected and private are placed
in front of each definition for each member in your class, whether it’s a
data member or a method.
Each access specifier controls the access for only that particular
definition.
“Friendly”
The default access has no keyword, but it is commonly referred to as
“friendly.”
It means that all the other classes in the current package have access to
the friendly member, but to all the classes outside of this package the
member appears to be private.
Since a compilation unit – a file – can belong only to a single package,
all the classes within a single compilation unit are automatically friendly
with each other.
46. public:
When you use the public keyword, it means that the member
declaration that immediately follows public is available to everyone,
private:
The private keyword that means no one can access that member except
that particular class, inside methods of that class.
protected: “sort of friendly”
Can be accessed from subclass in different package
A class cannot be private or protected.
So you have only two choices for class access: “friendly” or public.
47. Class Member Accessibility
Accessible to: public protected package private
Same class yes yes yes yes
subClass in same yes yes yes no
package
Subclass in yes yes no no
different package
Non-subclass,
different package yes no no no
49. Inheritance : Extending a Class
class A
{ int i; }
class B extends A // B is a subclass of A
{ int j; }
class I1{
public static void main(String args[])
{ B ob = new B();
ob.i=10;
ob.j=20;
System.out.println("ob's value =" + ob.i +"," + ob.j);
}}
50. class Rect { private int w,h;
void set(int x,int y)
{ w=x; h=y;
}
int area()
{ return w*h; }
void disp()
{
System.out.println("Width =" +w +", Height = " + h + "Area ="
+area());
}
}
Example 2
51. class Box extends Rect {
int d;
void set(int x,int y,int z)
{ set(x,y);
d=z;
}
void put()
{ disp();
System.out.println("Depth =" + d);
}
}
52. class I3
{
public static void main(String args[])
{
Box ob = new Box();
ob.set(10,20,15);
ob.put();
}
}
53. Constructor Chaining
class A
{ int i;
public A()
{ // Implicit call to super(); here.
i = 3; }
}
class B extends A
{
// Default constructor:
public B() { super(); }
}
55. Shadowed Variables
class A { int x=10; }
class B extends A { int x=20; }
class C extends B { int x=30;
void disp()
{ // Variable x in class C.
System.out.println("x in C is :" + x);
// Variable x in class B.
System.out.println("x in B is :" + super.x);
System.out.println("x in B is :" + ((B)this).x);
// Variable x in class A.
System.out.println("x in A is :" + ((A)this).x);
56. public static void main(String args[])
{
C obj = new C();
obj.disp();
}
}
57. Overriding Is Not Shadowing
Method overriding is not like variable shadowing at all:
You can refer to shadowed variables simply by casting an object to the
appropriate type.
You cannot invoke overridden methods with this technique.
Method Overriding versus Variable Shadowing
class A {
int i = 1;
int f() { return i; }
}
58. class B extends A
{
int i = 2; // Shadows variable i in class A.
int f() { return -i; } // Overrides method f in class A.
}
public class override_test
{ public static void main(String args[]) {
B b = new B();
System.out.println(b.i); // Refers to B.i; prints 2.
System.out.println(b.f()); // Refers to B.f(); prints -2.
A a = (A) b; // Cast b to an instance of class A.
System.out.println(a.i); // Now refers to A.i; prints 1;
System.out.println(a.f()); // Still refers to B.f(); prints -2; } }