You are on page 1of 6

JAVA ASSIGNMENT

Deepanshu

IT-1 (06011503121)

Q1 - Operators in Java:

In Java, operators are symbols used to perform operations on


operands. There are several types of operators in Java, including
arithmetic, relational, logical, bitwise, assignment, and conditional
operators.

Operators:

1. Arithmetic operators:
Arithmetic operators are used to perform basic mathematical
operations like addition, subtraction, multiplication, division, and
modulus. The plus (+) operator is used to add two numbers or
concatenate strings. The minus (-) operator is used to subtract one
number from another. The asterisk (*) operator is used to multiply two
numbers. The forward slash (/) operator is used to divide one number
by another. The modulus (%) operator is used to find the remainder
when one number is divided by another.
2. Relational operators:
Relational operators are used to compare two values and return a
boolean result (true or false). The equal to (==) operator is used to
check if two values are equal. The not equal to (!=) operator is used to
check if two values are not equal. The greater than (>) operator is
used to check if one value is greater than another. The less than (<)
operator is used to check if one value is less than another. The
greater than or equal to (>=) operator is used to check if one value is
greater than or equal to another. The less than or equal to (<=)
operator is used to check if one value is less than or equal to another.

3. Logical operators:
Logical operators are used to combine two or more boolean
expressions and return a boolean result. The AND (&&) operator is
used to check if both expressions are true. The OR (||) operator is
used to check if either expression is true. The NOT (!) operator is used
to invert the result of a boolean expression.

4. Bitwise operators:
Bitwise operators are used to perform bit-level operations on integer
types. The bitwise AND (&) operator performs a bitwise AND
operation on two values. The bitwise OR (|) operator performs a
bitwise OR operation on two values. The bitwise XOR (^) operator
performs a bitwise XOR operation on two values. The bitwise
complement (~) operator performs a bitwise complement operation on
a value.
5. Assignment operators:
Assignment operators are used to assign values to variables. The
simple assignment (=) operator is used to assign a value to a variable.
The addition assignment (+=) operator is used to add a value to a
variable and assign the result to the same variable. The subtraction
assignment (-=) operator is used to subtract a value from a variable
and assign the result to the same variable. The multiplication
assignment (*=) operator is used to multiply a variable by a value and
assign the result to the same variable. The division assignment (/=)
operator is used to divide a variable by a value and assign the result
to the same variable. The modulus assignment (%=) operator is used
to find the remainder when a variable is divided by a value and assign
the result to the same variable.

6. Conditional operator:
The conditional operator (also known as the ternary operator) is a
shorthand way of writing if-then-else statements. It has the syntax:
condition ? expression1 : expression2. If the condition is true,
expression1 is evaluated and returned. If the condition is false,
expression2 is evaluated and returned.
Q2 - Security promises of the JVM Java,
security architecture and security policy:
Java Virtual Machine (JVM) provides a secure environment
for running Java programs. Some of the security promises of
the JVM include:

Security Promises of the JVM:

The JVM (Java Virtual Machine) provides several security features


that make it a safe environment for executing Java applications. Some
of these security features are:

1. Bytecode verification: Before executing a Java program, the


JVM verifies the bytecode to ensure that it is valid and does not
violate any security policies. This verification process includes
checking the format of the bytecode, verifying that the code is
type-safe, and detecting any illegal or malicious code.

2. Class loading: The JVM loads classes from trusted sources and
ensures that the loaded classes do not violate any security
policies. The JVM also provides mechanisms for isolating
classes from different sources and preventing them from
interacting with each other in unauthorized ways.
3. Memory management: The JVM uses a garbage collector to
manage memory allocation and deallocation, which prevents
buffer overflows and other memory-related vulnerabilities.

4. Security manager: The JVM provides a security manager that


enforces a security policy and controls access to system
resources like files, sockets, and network interfaces.

Java Security Architecture:

The Java security architecture is a set of APIs and tools that provide
security services to Java applications. Some of the key components of
the Java security architecture are:

1. Security APIs: Java provides a set of security APIs that allow


developers to implement various security features like
encryption, digital signatures, and secure communication.

2. Java Authentication and Authorization Service (JAAS):


JAAS is a Java API that provides a framework for authentication
and authorization. JAAS allows applications to use different
authentication mechanisms and authorization policies based on
the user's role and privileges.
3. Java Cryptography Architecture (JCA): JCA is a set of APIs
for performing cryptographic operations like encryption,
decryption, and hashing. JCA provides a pluggable architecture
that allows developers to use different cryptographic providers
and algorithms.

4. Key Management: Java provides APIs for managing


cryptographic keys and certificates, which are used for secure
communication and authentication.

Java Security Policy:

Java security policy is a set of rules that define the permissions


granted to Java applications. These rules are defined in a policy file,
which is a plain text file that specifies the permissions for different
code sources and codebase URLs. The Java security policy provides
a way to limit the permissions of Java applications based on their
origin and intended use. The policy file can be customized to grant or
deny permissions to specific code sources, and it can be updated as
new security vulnerabilities are discovered. The security policy can be
enforced by the security manager, which is a built-in component of the
JVM.

You might also like