0% found this document useful (0 votes)
19 views

Lecture 1

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Lecture 1

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

Introduction to Programming

Java
Lecture 1
Programming
Programming is the process of creating instructions that tell a
computer what to do. It involves writing code using a programming
language, which is a set of rules and syntax that computers can
understand.
Why Learn Programming?
• Problem-solving: Programming helps you develop logical thinking and
problem-solving skills.
• Automation: You can automate repetitive tasks and create tools to
make your life easier.
• Creativity: Programming allows you to build your own digital
creations, from games to websites.
• Career opportunities: Programming skills are highly sought after in
various industries.
Basic Programming Concepts:
• Variables: Containers that store data (e.g., numbers, text).
• Data types: Different types of data (e.g., integers, floating-point
numbers, strings).
• Operators: Symbols used to perform operations on data (e.g.,
arithmetic, comparison).
• Control flow: Statements that determine the order in which code is
executed (e.g., if-else, loops).
• Functions: Reusable blocks of code that perform specific tasks.
Understanding Programming Basics
• What is Programming?
• Programming involves writing code to solve problems or automate
tasks.
• Key concepts include variables, data types, control structures (if-else,
loops), and functions/methods.
Programming Paradigms:
• Procedural Programming: Focuses on functions or procedures to
operate on data.
• Object-Oriented Programming (OOP): Centers around objects and
classes, which bundle data and behavior together.
Compilation vs. Interpretation:
Java code is first compiled into bytecode, which is then executed
by the JVM. This compilation process makes Java both efficient and
platform-independent.
Introduction to
Programming in Java
Programming in Java
Java is a high-level, object-oriented programming language that
is widely used for developing a variety of applications, from web and
mobile apps to enterprise software and scientific simulations. Its
popularity stems from its portability, robustness, and security.
What is Java?
Developed by Sun Microsystems in 1995, Java is a highly
popular, object-oriented programming language. This platform
independent programming language is utilized for Android
development, web development, artificial intelligence, cloud
applications, and much more.
Java is a popular programming language, created in
1995.

It is owned by Oracle, and more than 3


billion devices run Java.
What is Java?
Java is one of the most popular and widely used programming
languages and platforms. A platform is an environment that helps to
develop and run programs written in any programming language.
Java is fast, reliable, and secure. From desktop to web applications,
scientific supercomputers to gaming consoles, cell phones to the
Internet, Java is used in every nook and corner.
Features of Java
• Java is a simple language: Java is easy to learn and its syntax is clear and concise. It
is based on C++. Java has removed many confusing and rarely-used features e.g.
explicit pointers, operator overloading, etc. Java also takes care of memory
management and it also provides an automatic garbage collector. This collects the
unused objects automatically.
• Java is a platform-independent language: The programs written in Java language,
after compilation, are converted into an intermediate level language called
the bytecode which is a part of the Java platform irrespective of the machine on
which the programs run. This makes java highly portable as its bytecodes can be
run on any machine by an interpreter called the Java Virtual Machine(JVM) and
thus java provides 'reusability of code'.
• Java is an object-oriented programming language: OOP makes the complete
program simpler by dividing it into a number of objects. The objects can be used as
a bridge to have data flow from one function to another. We can easily modify data
and function's as per the requirements of the program.
• Java is a secure language: Java is recognized for its security features;
Java's security features include-
• No use of pointer directly:
• Its robust sandbox environment: A robust sandbox environment
refers to a secure and isolated execution environment where software
programs can run safely without affecting the rest of the system. In
the context of Java, the Java Virtual Machine (JVM) provides this
sandbox environment.
JVM (java Virtual Machine)- Java code is compiled into bytecode,
which is executed by the JVM. The JVM provides a controlled execution
environment, enforcing strict access controls and runtime security checks.
This isolation helps prevent unauthorized access to system resources and
protects against many common security threats.

Operating System (OS) Execution: C++ programs are typically


compiled into machine code that directly interacts with the operating
system. While this offers more direct control over system resources, it also
increases the risk of security vulnerabilities, such as buffer overflows and
memory corruption, if not managed carefully.
Java is a robust(strong) language: Here’s is
what makes java a robust language-
• Bytecode Verification: Before executing Java bytecode, the JVM performs bytecode
verification to ensure that it adheres to the language's rules and does not violate security
constraints. This process helps prevent certain types of security vulnerabilities, such as
buffer overflows or type mismatches.
• Memory Management: Java's automatic memory management, handled by the JVM's
garbage collector, helps prevent memory-related security vulnerabilities like memory
leaks or dangling pointers. The garbage collector deallocates memory automatically,
reducing the risk of unauthorized access to memory locations.
• Security Manager: Java's security model includes a Security Manager component that
defines a set of permissions for Java code. The Security Manager enforces these
permissions to control what actions Java programs can perform, such as reading or
writing files, opening network connections, or accessing system properties.
• ClassLoader: ClassLoader in Java is responsible for loading classes into memory at
runtime. It works by searching for classes in various sources such as the classpath, and
when requested, loads the bytecode of a class file into memory for execution.
ClassLoader provide the foundation for access control, code integrity, and runtime
security enforcement. By leveraging ClassLoaders effectively, Java applications can
maintain a secure and robust runtime environment.
• Java is a multithreaded language: Java can perform many tasks at
once by defining multiple threads. For example, a program that
manages a Graphical User Interface (GUI) while waiting for input from
a network connection uses another thread to perform and wait's
instead of using the default GUI thread for both tasks. This keeps the
GUI responsive.
• Java programs can create applets: Applets are programs that run in
web browsers. But applets support was deprecated in Java 9 release
and has been removed in Java 11 release due to waning browser
support for the Java plugin.
• Java does not require any preprocessor: It does not require inclusion
of header files for creating a Java application.
Key Features of Java:
• Object-Oriented: Java follows the object-oriented paradigm, which
emphasizes the organization of code around objects and their interactions.
• Platform-Independent: Java code can be compiled into bytecode, which can
run on any platform with a Java Virtual Machine (JVM) installed. This makes
Java highly portable.
• Robust: Java has strong type checking and automatic memory management,
which helps prevent common programming errors.
• Secure: Java is designed with security in mind, and it includes features like
garbage collection and exception handling to enhance security.
• Scalable: Java can handle large-scale applications and can be easily scaled to
meet growing demands.
Variables and Data Types:
Java supports various data types to represent different kinds of
values:

• Primitive Data Types:


• Reference Data Types:
Primitive Data Types:
• byte: 8-bit signed integer
• short: 16-bit signed integer
• int: 32-bit signed integer
• long: 64-bit signed integer
• float: 32-bit floating-point number
• double: 64-bit floating-point number
• char: 16-bit Unicode character
• boolean: Boolean value (true or false)
Reference Data Types:

• Classes
• Interfaces
• Arrays
Conclusion
• Java works on different platforms
• It is one of the most popular programming languages in the world
• It has a large demand in the current job market
• It is easy to learn and simple to use
• It is open-source and free
• It is secure, fast and powerful
• It has huge community support (tens of millions of developers)
• Java is an object oriented language which gives a clear structure
to programs and allows code to be reused, lowering development
costs
• As Java is close to C++ and C#, it makes it easy for programmers
to switch to Java or vice versa

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy