This begins your journey to java as a very beginner. Prerequisite of the audience is strong understanding of basic language fundamentals of C or C++ or C# .
This shows how one can use XMPP in one's Java coding to make an IM communication. It'd be really amusing to see your Facebook or Google chat in action with your own code.
This presentation provides the information on python including the topics Python features, applications, variables and operators in python, control statements, numbers, strings, print formatting, list and list comprehension, dictionaries, tuples, files, sets, boolean, mehtods and functions, lambda expressions and a sample project using Python.
Augmenting and structuring user queries to support efficient free-form code s...Dongsun Kim
Presented at the 40th International Conference on Software Engineering, May 27 - 3 June 2018, Gothenburg, Sweden (ICSE 2018) as Journal first publication.
This shows how one can use XMPP in one's Java coding to make an IM communication. It'd be really amusing to see your Facebook or Google chat in action with your own code.
This presentation provides the information on python including the topics Python features, applications, variables and operators in python, control statements, numbers, strings, print formatting, list and list comprehension, dictionaries, tuples, files, sets, boolean, mehtods and functions, lambda expressions and a sample project using Python.
Augmenting and structuring user queries to support efficient free-form code s...Dongsun Kim
Presented at the 40th International Conference on Software Engineering, May 27 - 3 June 2018, Gothenburg, Sweden (ICSE 2018) as Journal first publication.
Reverse-engineering: Using GDB on LinuxRick Harris
At Holberton School, we have had a couple rounds of a ‘#forfun’ project called crackme. For these projects, we are given an executable that accepts a password. Our assignment is to crack the program through reverse engineering.
This is one of my old slide. I took an one day class in BRAC University in 2007 on taking input in Java programming language. This tutorial is for begginer studemts.
Don't be fooled by the thumbnail - the first couple of slides are a silly joke I forgot to remove before uploading.
Presentation derived from the "What's new in Python 2.4" document on http://www.python.org/ including much reformatting for presenting and presenter notes.
Please download the Keynote original - that way the presentation notes aren't burned into the slides.
Threads And Synchronization in C#
Concept about Threads And Synchronization in C#
it will help you about this concept
feel free
Download free programming applications on
http://www.androidapplications.xyz
Std 12 Computer Chapter 7 Java Basics (Part 1) by Nuzhat Memon
Introduction to Java
Java Development Kit (JDK)
Java Runtime Environment (JRE)
java is a platform independent
Bytecode in java
java interpreter
Structure of a java program
literals in java
3 kinds of comments in java (single line comment, multiline comment, documentation comment)
Expression in java
Operator in java
Looping in java
continue and break statement in java
gseb computer paper solution 2020 english medium
Concurrent Programming in Java provides a brief overview of the following topics:
• Java language support for concurrency
• Concurrency utilities (java.util.concurrent package)
• Java collections for multithreading (java.util package)
• Parallel streams in Java 8.
Try out the examples. Source code here: https://github.com/CodeOpsTech/ConcurrentJava
This has been presented in association with Robosepians for Java concepts. Basic concepts of Java including features, conditional statements, loop statements, arrays, string, primitive datatypes, essentials of Java including oops concepts, classes, objects, polymorphism, advance topics including packages, exception handling, multihtreading and network programming have been discussed.
Reverse-engineering: Using GDB on LinuxRick Harris
At Holberton School, we have had a couple rounds of a ‘#forfun’ project called crackme. For these projects, we are given an executable that accepts a password. Our assignment is to crack the program through reverse engineering.
This is one of my old slide. I took an one day class in BRAC University in 2007 on taking input in Java programming language. This tutorial is for begginer studemts.
Don't be fooled by the thumbnail - the first couple of slides are a silly joke I forgot to remove before uploading.
Presentation derived from the "What's new in Python 2.4" document on http://www.python.org/ including much reformatting for presenting and presenter notes.
Please download the Keynote original - that way the presentation notes aren't burned into the slides.
Threads And Synchronization in C#
Concept about Threads And Synchronization in C#
it will help you about this concept
feel free
Download free programming applications on
http://www.androidapplications.xyz
Std 12 Computer Chapter 7 Java Basics (Part 1) by Nuzhat Memon
Introduction to Java
Java Development Kit (JDK)
Java Runtime Environment (JRE)
java is a platform independent
Bytecode in java
java interpreter
Structure of a java program
literals in java
3 kinds of comments in java (single line comment, multiline comment, documentation comment)
Expression in java
Operator in java
Looping in java
continue and break statement in java
gseb computer paper solution 2020 english medium
Concurrent Programming in Java provides a brief overview of the following topics:
• Java language support for concurrency
• Concurrency utilities (java.util.concurrent package)
• Java collections for multithreading (java.util package)
• Parallel streams in Java 8.
Try out the examples. Source code here: https://github.com/CodeOpsTech/ConcurrentJava
This has been presented in association with Robosepians for Java concepts. Basic concepts of Java including features, conditional statements, loop statements, arrays, string, primitive datatypes, essentials of Java including oops concepts, classes, objects, polymorphism, advance topics including packages, exception handling, multihtreading and network programming have been discussed.
This talk introduces the core concepts of functional programming, why it matters now and how these principles are adopted for programming.
Beyond the usage of the functional principles for programming in the small, their applicability to the design of components and further on to the architecture of software systems is also explored along with relevant examples.
The code samples used in the talk are in Haskell / Java 8 / Scala / Elm and JavaScript, but deep understanding of any of these languages are not a pre-requisite.
Describes Bluetooth protocol in the application layer, Uses Java to explore Bluetooth technology using JSR-82. Has separate discussions for :
1) concept of local and remote device
2) Find out your own MAC Address (Bluetooth )
3) Search for devices
4)Connect to a device over BTSPP
5) Use javax.microedition.io
6) It also works with Java ME (J2ME)
7) concept of UUID and profiles
9) It connects to DUN profile
10) Using AT commands to ethically make calls from another GSM mobile or send SMS from it
This is one of the comprehensive Java slides I made in 2008.
This covers:
a) Constructors
b) static initializers and blocks
c) non-static initializers and blocks
d) this keyword
e) chaining of constructors
This Java slides gives comprehensive understating of :
a) Inheritance
b) super keyword and constructors
c) hierarchical super constructor and execution of blocks and initilaizers
d) static methods and their speciality
e) Method overriding versus overloading
f) why static methods cannot be overridden
h) private methods : why they are not overridden
g) rules of overriding :Exceptions to be thrown
h) dynamic method dispatch what and why
Java Universal super class java.lang.Object is discussed comprehensively with code snippets.
Also covers:
a) Why we need inheritance and dynamic method dispatch
b) Need of a universal parent
c) Delegation and proxies
d) toString(), clone(), equals(), notify()
Comprehensive guide with code snippet that discusses:
1) how an HTML table can be used to select rows from
2) how to render a dynamic table using database
3) How and why to alternate row colors on even-'n'-odd basis
Designing for Privacy in Amazon Web ServicesKrzysztofKkol1
Data privacy is one of the most critical issues that businesses face. This presentation shares insights on the principles and best practices for ensuring the resilience and security of your workload.
Drawing on a real-life project from the HR industry, the various challenges will be demonstrated: data protection, self-healing, business continuity, security, and transparency of data processing. This systematized approach allowed to create a secure AWS cloud infrastructure that not only met strict compliance rules but also exceeded the client's expectations.
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...informapgpstrackings
Keep tabs on your field staff effortlessly with Informap Technology Centre LLC. Real-time tracking, task assignment, and smart features for efficient management. Request a live demo today!
For more details, visit us : https://informapuae.com/field-staff-tracking/
Your Digital Assistant.
Making complex approach simple. Straightforward process saves time. No more waiting to connect with people that matter to you. Safety first is not a cliché - Securely protect information in cloud storage to prevent any third party from accessing data.
Would you rather make your visitors feel burdened by making them wait? Or choose VizMan for a stress-free experience? VizMan is an automated visitor management system that works for any industries not limited to factories, societies, government institutes, and warehouses. A new age contactless way of logging information of visitors, employees, packages, and vehicles. VizMan is a digital logbook so it deters unnecessary use of paper or space since there is no requirement of bundles of registers that is left to collect dust in a corner of a room. Visitor’s essential details, helps in scheduling meetings for visitors and employees, and assists in supervising the attendance of the employees. With VizMan, visitors don’t need to wait for hours in long queues. VizMan handles visitors with the value they deserve because we know time is important to you.
Feasible Features
One Subscription, Four Modules – Admin, Employee, Receptionist, and Gatekeeper ensures confidentiality and prevents data from being manipulated
User Friendly – can be easily used on Android, iOS, and Web Interface
Multiple Accessibility – Log in through any device from any place at any time
One app for all industries – a Visitor Management System that works for any organisation.
Stress-free Sign-up
Visitor is registered and checked-in by the Receptionist
Host gets a notification, where they opt to Approve the meeting
Host notifies the Receptionist of the end of the meeting
Visitor is checked-out by the Receptionist
Host enters notes and remarks of the meeting
Customizable Components
Scheduling Meetings – Host can invite visitors for meetings and also approve, reject and reschedule meetings
Single/Bulk invites – Invitations can be sent individually to a visitor or collectively to many visitors
VIP Visitors – Additional security of data for VIP visitors to avoid misuse of information
Courier Management – Keeps a check on deliveries like commodities being delivered in and out of establishments
Alerts & Notifications – Get notified on SMS, email, and application
Parking Management – Manage availability of parking space
Individual log-in – Every user has their own log-in id
Visitor/Meeting Analytics – Evaluate notes and remarks of the meeting stored in the system
Visitor Management System is a secure and user friendly database manager that records, filters, tracks the visitors to your organization.
"Secure Your Premises with VizMan (VMS) – Get It Now"
First Steps with Globus Compute Multi-User EndpointsGlobus
In this presentation we will share our experiences around getting started with the Globus Compute multi-user endpoint. Working with the Pharmacology group at the University of Auckland, we have previously written an application using Globus Compute that can offload computationally expensive steps in the researcher's workflows, which they wish to manage from their familiar Windows environments, onto the NeSI (New Zealand eScience Infrastructure) cluster. Some of the challenges we have encountered were that each researcher had to set up and manage their own single-user globus compute endpoint and that the workloads had varying resource requirements (CPUs, memory and wall time) between different runs. We hope that the multi-user endpoint will help to address these challenges and share an update on our progress here.
Listen to the keynote address and hear about the latest developments from Rachana Ananthakrishnan and Ian Foster who review the updates to the Globus Platform and Service, and the relevance of Globus to the scientific community as an automation platform to accelerate scientific discovery.
We describe the deployment and use of Globus Compute for remote computation. This content is aimed at researchers who wish to compute on remote resources using a unified programming interface, as well as system administrators who will deploy and operate Globus Compute services on their research computing infrastructure.
Modern design is crucial in today's digital environment, and this is especially true for SharePoint intranets. The design of these digital hubs is critical to user engagement and productivity enhancement. They are the cornerstone of internal collaboration and interaction within enterprises.
Strategies for Successful Data Migration Tools.pptxvarshanayak241
Data migration is a complex but essential task for organizations aiming to modernize their IT infrastructure and leverage new technologies. By understanding common challenges and implementing these strategies, businesses can achieve a successful migration with minimal disruption. Data Migration Tool like Ask On Data play a pivotal role in this journey, offering features that streamline the process, ensure data integrity, and maintain security. With the right approach and tools, organizations can turn the challenge of data migration into an opportunity for growth and innovation.
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns
Unlocking Business Potential: Tailored Technology Solutions by Prosigns
Discover how Prosigns, a leading technology solutions provider, partners with businesses to drive innovation and success. Our presentation showcases our comprehensive range of services, including custom software development, web and mobile app development, AI & ML solutions, blockchain integration, DevOps services, and Microsoft Dynamics 365 support.
Custom Software Development: Prosigns specializes in creating bespoke software solutions that cater to your unique business needs. Our team of experts works closely with you to understand your requirements and deliver tailor-made software that enhances efficiency and drives growth.
Web and Mobile App Development: From responsive websites to intuitive mobile applications, Prosigns develops cutting-edge solutions that engage users and deliver seamless experiences across devices.
AI & ML Solutions: Harnessing the power of Artificial Intelligence and Machine Learning, Prosigns provides smart solutions that automate processes, provide valuable insights, and drive informed decision-making.
Blockchain Integration: Prosigns offers comprehensive blockchain solutions, including development, integration, and consulting services, enabling businesses to leverage blockchain technology for enhanced security, transparency, and efficiency.
DevOps Services: Prosigns' DevOps services streamline development and operations processes, ensuring faster and more reliable software delivery through automation and continuous integration.
Microsoft Dynamics 365 Support: Prosigns provides comprehensive support and maintenance services for Microsoft Dynamics 365, ensuring your system is always up-to-date, secure, and running smoothly.
Learn how our collaborative approach and dedication to excellence help businesses achieve their goals and stay ahead in today's digital landscape. From concept to deployment, Prosigns is your trusted partner for transforming ideas into reality and unlocking the full potential of your business.
Join us on a journey of innovation and growth. Let's partner for success with Prosigns.
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus
As part of the DOE Integrated Research Infrastructure (IRI) program, NERSC at Lawrence Berkeley National Lab and ALCF at Argonne National Lab are working closely with General Atomics on accelerating the computing requirements of the DIII-D experiment. As part of the work the team is investigating ways to speedup the time to solution for many different parts of the DIII-D workflow including how they run jobs on HPC systems. One of these routes is looking at Globus Compute as a way to replace the current method for managing tasks and we describe a brief proof of concept showing how Globus Compute could help to schedule jobs and be a tool to connect compute at different facilities.
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...Hivelance Technology
Cryptocurrency trading bots are computer programs designed to automate buying, selling, and managing cryptocurrency transactions. These bots utilize advanced algorithms and machine learning techniques to analyze market data, identify trading opportunities, and execute trades on behalf of their users. By automating the decision-making process, crypto trading bots can react to market changes faster than human traders
Hivelance, a leading provider of cryptocurrency trading bot development services, stands out as the premier choice for crypto traders and developers. Hivelance boasts a team of seasoned cryptocurrency experts and software engineers who deeply understand the crypto market and the latest trends in automated trading, Hivelance leverages the latest technologies and tools in the industry, including advanced AI and machine learning algorithms, to create highly efficient and adaptable crypto trading bots
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Shahin Sheidaei
Games are powerful teaching tools, fostering hands-on engagement and fun. But they require careful consideration to succeed. Join me to explore factors in running and selecting games, ensuring they serve as effective teaching tools. Learn to maintain focus on learning objectives while playing, and how to measure the ROI of gaming in education. Discover strategies for pitching gaming to leadership. This session offers insights, tips, and examples for coaches, team leads, and enterprise leaders seeking to teach from simple to complex concepts.
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Globus
The U.S. Geological Survey (USGS) has made substantial investments in meeting evolving scientific, technical, and policy driven demands on storing, managing, and delivering data. As these demands continue to grow in complexity and scale, the USGS must continue to explore innovative solutions to improve its management, curation, sharing, delivering, and preservation approaches for large-scale research data. Supporting these needs, the USGS has partnered with the University of Chicago-Globus to research and develop advanced repository components and workflows leveraging its current investment in Globus. The primary outcome of this partnership includes the development of a prototype enterprise repository, driven by USGS Data Release requirements, through exploration and implementation of the entire suite of the Globus platform offerings, including Globus Flow, Globus Auth, Globus Transfer, and Globus Search. This presentation will provide insights into this research partnership, introduce the unique requirements and challenges being addressed and provide relevant project progress.
Understanding Globus Data Transfers with NetSageGlobus
NetSage is an open privacy-aware network measurement, analysis, and visualization service designed to help end-users visualize and reason about large data transfers. NetSage traditionally has used a combination of passive measurements, including SNMP and flow data, as well as active measurements, mainly perfSONAR, to provide longitudinal network performance data visualization. It has been deployed by dozens of networks world wide, and is supported domestically by the Engagement and Performance Operations Center (EPOC), NSF #2328479. We have recently expanded the NetSage data sources to include logs for Globus data transfers, following the same privacy-preserving approach as for Flow data. Using the logs for the Texas Advanced Computing Center (TACC) as an example, this talk will walk through several different example use cases that NetSage can answer, including: Who is using Globus to share data with my institution, and what kind of performance are they able to achieve? How many transfers has Globus supported for us? Which sites are we sharing the most data with, and how is that changing over time? How is my site using Globus to move data internally, and what kind of performance do we see for those transfers? What percentage of data transfers at my institution used Globus, and how did the overall data transfer performance compare to the Globus users?
Large Language Models and the End of ProgrammingMatt Welsh
Talk by Matt Welsh at Craft Conference 2024 on the impact that Large Language Models will have on the future of software development. In this talk, I discuss the ways in which LLMs will impact the software industry, from replacing human software developers with AI, to replacing conventional software with models that perform reasoning, computation, and problem-solving.
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...Juraj Vysvader
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I didn't get rich from it but it did have 63K downloads (powered possible tens of thousands of websites).
Software Engineering, Software Consulting, Tech Lead.
Spring Boot, Spring Cloud, Spring Core, Spring JDBC, Spring Security,
Spring Transaction, Spring MVC,
Log4j, REST/SOAP WEB-SERVICES.
Unleash Unlimited Potential with One-Time Purchase
BoxLang is more than just a language; it's a community. By choosing a Visionary License, you're not just investing in your success, you're actively contributing to the ongoing development and support of BoxLang.
Using IESVE for Room Loads Analysis - Australia & New Zealand
Core java day1
1. Origin of Java
• World War-2 need of a platform independent
language
• Green by Sun Micro Systems comes up
• Fails due to marketing issues et al
• Analog-to-Digital Transit, Computer H/W
advancement, Concept of World Wide Web and
Internet, Need of security
• Green transformed to Oak
• 1994 Java makes official release
sohamsengupta@yahoo.com1
2. Three Editions of Java
• J2SE (Java 2 Standard Edititon)
• J2EE (Java 2 Enterprise Edition)
• J2ME (Java 2 Micro Edition)
sohamsengupta@yahoo.com2
3. Java Data Types
Numeric: 1. Whole Numbers
sohamsengupta@yahoo.com3
2. Fractions
Whole Numbers: byte 1 byte default value 0
short2 bytes default value 0
int 4 bytes default value 0
long 8 bytes default value 0
Fractions: float 4 bytes default value 0.0f
double 8 bytes default value 0 .0
Symbolic: char 2 bytes (Sun Unicode Character) default
value‘u0000’
Logical : boolean 1 byte default value false
User Defined: class and interface (to be described later on)
4. Your First Java Program
• In C consider the code snippet…
#include<stdio.h>
void main(){
printf(“Hello From Soham”);
sohamsengupta@yahoo.com4
}•
The corresponding Java Code would be…
class A
{
public static void main(String[] args){
System.out.print(“Hello from Soham”);
}}
5. Before I say more on Java some Do’s
Soham was writing a program as on LHS. After typing out 1000 lines he
felt he needed an extra statement in if branch, but poor Soham! What he
did was
sohamsengupta@yahoo.com5
• if(condition)
statement-1;
statement-2;
.
.
.
Statement-1000;
• if(condition)
statement-1;
ssttaatteemmeenntt--11AA;;
statement-2;
.
.
.
Statement-1000
6. Poor Me! I intended something else
I was supposed to type…
• if(condition){
sohamsengupta@yahoo.com6
statement-1;
ssttaatteemmeenntt--11AA;;
}}
statement-2;
.
.
.
statement-1000
• Moral:
1. When you come across some
if-else branch, or for, while,
switch, or any method or
block, at once type out the
braces and then carry on with
your code
2. It’ll not only save you from
my condition, but also it’ll
save you quite a lot of time of
compilation errors saying…
“ } required”
7. More on Java
Answers to some FAQ about Java 2
• A java file is saved in .java extension
• A java file, if successfully compiled, produces x+y number of .class
files where x and y are the number of classes and interfaces in that
file
• In java, you can’t put anything except comments outside a class or
sohamsengupta@yahoo.com7
interface block
• To run java program you need Java Virtual Machine(JVM) which
comes as a part of JDK.
• Successful compilation generates .class files which contain byte
codes that is interpreted by JVM. So, java development generally
uses both compiler and interpreter.
• Java Byte codes are platform independent but JVM is different for
different Operating Systems.
8. Features of Java 2 (J2SE 1.4)
1. Platform independent…means runs on any HW+OS environment
2. Java was developed using C++ but excludes the features like
sohamsengupta@yahoo.com8
pointers.
3. Java is a purely typed language as it does not allow automatic type
demotion (More on this later on)
4. Java is object oriented, secure due to its various security features,
reusable and portable,form-free and case sensitive and supports
general logical statements like C/C++
5. Java is not only platform friendly but also is very much developer
friendly. As support of this statement, Java does not have concept of
garbage value. It will never let the program perform read operation
on a non initialized local variable .Also, it saves you from getting
tampered data due to overflow and/or underflow since it doesn’t
allow automatic type demotion
9. Java Source File Name & Class Name
1. A java source file may contain any number of classes and interfaces
and there is no such hard-and-first rule that file name and class/
interface name should have relation…. But wait friends, this is
applicable as long as the file contains no public class/interface.
More concisely, a java source file must have the same name as that
of the public class/interface in it. It’s thus implied that a java source
file can contain one and only one public class/interface
2. To compile a Java file, say, A.java you have to give the command
sohamsengupta@yahoo.com9
…>javac A.java
3. If successful compilation occurs, you will surely want to run it. And
your command is going to be …> java MyClass where MyClass is
the class inside A.java that has then main method.
4. Remember, MyClass need not always have the main method.
10. My Second Java Program
#include<stdio.h>
void main()
{
int x=940;
printf(“U scored good marksn”);
printf(“Your marks is %d”,x);
sohamsengupta@yahoo.com10
}
class A
{
public static void main(String[] ar)
{
int x=940;
System.out.println(“U scored good
marks”);
System.out.print(“Your marks is ”+x);
}
}
11. Printing an output on the console
• We generally use the syntax System.out.print() or System.out.println()
to output text on the console. Difference between them is that println()
can be used with no arguments where as print() can’t be used without
an argument. Also, println() automatically appends a trailing new line
character (‘n’)
• Don’t ask me more about System.out because my plan is to climb up
the Java tree step by step and I don’t want to stumble down the stairs.
Yet, FYI, System is class under java.lang package and out is an static
object belonging to System class and of type java.io.PrintStream.
• Note the syntax: System.out.print(“Your marks is ”+x);
• Here + is concatenation operator instead and apart
from being the traditional addition operator.
sohamsengupta@yahoo.com11
12. Dual Nature of + operator
Look at the code snippet below and see the outputs
int x=9; int y=6;
15
System.out.println(x+y);
int x=9; int y=6;
System.out.println(“Sum is ”+x+y);
Sum is 96
int x=9; int y=6;
System.out.println(“Sum is ”+(x+y));
Sum is 15
int x=9; int y=6;
System.out.println(“Product is ”+x*y);
Product is 54
int x=9; int y=6;
System.out.println(x+y+ “ is the sum”);
15 is the sum
int x=9; int y=6;
System.out.println(x-y+ “ is difference”);
3 is difference
int x=9; int y=6;
System.out.println(“Difference is”+x-y);
Compilation error:
Operator – cannot be applied to
java.lang.String,int
sohamsengupta@yahoo.com12
13. From the Experts’ Desk
1. Since you can’t always afford to remember all the precedence rules and
this sort of things, the Java Guru recommends that you should always
use parentheses while using arithmetic expressions in the simplest way
2. As you are mostly accustomed to C/C++, first you’ll ask for a
counterpart of scanf() and cin>>. Yes. You can take input from console
through keyboard. But as I’ve told you, wait till I make you climb to
that level! Java, unlike C/C++ is not meant to be used as a mere
programming language with console as you did with Turbo C++,
generating Pascal triangles or Fibonacci Series et al.
3. Today java is more of a technology than of a language itself. Java can
carry out robust networking, enterprise web development to small
mobile device programming.
4. Note that Java handles all inputs as String, unlike C then tries to
convert to the intended type.
sohamsengupta@yahoo.com13
14. Java As a Typed language: code snippet
sohamsengupta@yahoo.com14
byte x=9;
System.out.println(x);
Here output will be 9 It’s OK to assign a value to
a type within range
byte x=129;
System.out.println(x);
Error: Possible loss of
precision: found int ,
required byte
Value beyond range. Range
of byte –128 to +127
byte x=(byte)129;
System.out.println(x);
Output: -127 (data
tampered due to overflow)
Explicit type casting may
cost you to worry later
int y=5; byte x=y;
System.out.println(x);
Error: Possible loss of
precision: found int ,
required byte
Though value is in range,
type int can’t be
automatically demoted.
int y=5; byte x=(byte)y;
System.out.println(x);
OK. Output: 5 Explicit type demotion ok
here but can cause OF/UF
long y=8; int x=y;
System.out.println(x);
Guess yourself Automatica type demotion
not allowed so error.
float x=9.8; // Error
Should be float x=9.8f;
Error: possible loss of
precision: found double
required float
9.8 is double and 9.8f/9.8F
is float. This is because java
is memory efficient
15. Java A Typed Language: Contd.
1. boolean is the only data type that can’t be converted to
any type nor any other type be converted to boolean.
2. Implicit type demotion is not allowed in java. You have
to do it explicitly. But before that make sure that it
causes no overflow and/or underflow or both.
3. Although char is 2 bytes and so is short, yet they are not
compatible. char is automatically converted to int or
higher. For hierarchy consult any standard book.
4. char is unsigned strictly in java and note the following.
char ch=-90; // Error
char ch=90; System.out.println(ch); // output : Z
char ch=90; System.out.println((int)ch);// output 90
sohamsengupta@yahoo.com15
16. Operators: Unary & Binary
1. Rule for Unary Operator:
“If the operand is of a type which is below int in the hierarchy, the
output is converted to int, else the type of the output is the type of
the operand.”
2. Rule for Binary Operator:
“ If the Binary operator takes 2 operators one of type T1 and the
other of type T2, and max(T1,T2) is less than or equal to int, the
output is converted to int itself, else the output is of type
max(T1,T2)”
This rule is not applicable to increment and decrement operators
Hold your breath dears! Lots of surprises await you in the next
slide.
sohamsengupta@yahoo.com16
17. Look at the code snippets below
sohamsengupta@yahoo.com17
byte x=9; x=-x;
System.out.println(x);
Error: Possible loss of
precision found: int
required: byte
Rule-1: inputbyte
Output int
byte x=9; byte y=x+1;
System.out.println(x);
Same Error Rule:2 i/p byte, int
O/p int
byte x=7; byte y=2;
short z=x+y;
Same Error! Apply Rule-2
long x=89; byte y=8;
int z=x+y;
Error! Apply Rule-2. Output is
of type long
byte x=9; x=x+8; Error Apply Rule-2: Output is
of type int
byte x=9; x+=8; x++; OK Rule-2 Not applicable
for += and ++ operator
char ch=‘%’; int x=100
System.out.println(x+ch
+ “ pure am I”);
Output 137 pure am I Be careful. To avoid
this, use parentheses or
String ch=“%”;
18. Note the Following
• byte x=‘c’; // is OK
• int x=12;
byte y=x; // Error
• final int x=12; byte y=x; // IS OK
• final int x=134; byte y=x; // Error out of range
• This holds only when source data is less than or
equal to int.
• Adding the keyword “final” before a variable
makes it constant. It can’t be changed and any
code to change this will result in compilation error
sohamsengupta@yahoo.com18
19. Note the following code snippets
public static void main(String[] args){
int x;
x++;
System.out.println(x);
}
Error: variable
x might not
have been
initialized.
In Java there is no concept
of garbage value. Without
initializing a local variable
u can’t perform read
operation on it.
sohamsengupta@yahoo.com19
int x;
if(6>4){x=8; }
System.out.println(x);
OK. Output will
be 8
6>4 is evaluated at compile
time. So, since it’s true
always, x must be
initialized.
int x;
if(6<4){ x=8;}
System.out.println(x);
Error:variable
x might not
have been
initialized.
6<4 is evaluated at compile
time. So, since it’s false
always, x must not be
initialized.
Replace numerics by variables say, a &
b. Observe the result, it’s error
if(a>b){ x=8;} System.out.print(x);
But making them final will be ok if a>b
is true
Error:variable
x might not
have been
initialized.
a>b or a<b is not evaluated
during compilation time.
So, it’s not sure if x is
initialized or not. Hence
Error