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

java material

java study material
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

java material

java study material
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Java

Java is a popular programming language owned by Oracle.it was devolped by


sun microsystems in year 1995. father of Java was James Gosling It is used
for Mobile applications (especially Android apps),
Desktop applications,
Web applications,
Web servers
application servers,
Games,
Database connection etc
 Features of java or java buzz words:
simple - very easy to learn,simple syntax,java donot have some of the
complicated features like pointers in c and operator overloading in C+
+

 Object oriented - java is an object oriented programming language.in


object oriented programming every thing is considered as an object
 Portable – java sourcecode is compiled to bytecode .this bytecode
generated can run on any that has jvm
Platform independent – java is a write-once-run-everywhere language and
can run on any operating system Because we can write java code in one system run on
another system. Java does not compile into machine code, it compiles into byte code and it will run
or be interpreted using JVM( java virtual machine). Which makes the Java platform independent.
 Secured - Java provides a strong Exception Handling mechanism,
making it more secure as it does not allow running the program until
you rectify the error.
 Java provides access modifier/access specifiers like private, protected,
public and default. It helps in controlling the access of any member.
 Finally, Java has several built-in security features that help to protect
applications and data. For example, Java's access control model allows
developers to restrict access to certain parts of an application based on
user roles. It helps to ensure that only authorized users can gain access
to sensitive data. it difficult for attackers to gain access to systems and
exploit any security vulnerabilities
o Robust - strong , it utilizes strong memory management. Like
Java automatically handles the memory management system.example
it has automatic garbage collection, which means the garbage
collector finds unused objects and deletes them to free up
memory. There is a lack of pointers that avoids security problems There
are exception handling and the type checking mechanism in Java.
All these points make Java robust

 Architectural neutral - The term "architecture-neutral" refers to Java's


ability to run on various hardware and software platforms without
modification also known as platform independence or write once, run
anywhere (WORA), is a fundamental concept in Java
 Interpreted - java is both compiled and interpreted programming
language it uses both compilation and interpretation to run code .first
the code is compiled into bytecode then byte code is interpreted by
jvm
 High performance – java offers high performance by using jit (just in
time compiler) compiler by compiling bytecodes into native
machine code at run time
 Multithreaded - java is a process of executing multiple threads
simultaneously. A thread is a lightweight sub-process
 Distributed - it facilitates users to create distributed .
applications in Java Java is a distributed programming language,
which means that it can be used to create programs that run on
multiple devices connected to a network. These programs can
communicate with each other and share data and resources, making it
easy to create distributed applications
 Dynamic - It supports the dynamic loading of classes. It means classes
are loaded on demand.

The sandbox is a set of rules that apply to all Java code running in
the JVM.
Object oriented languages follow bottom to top approach
In Java, every application begins with a class name, and that class must
match the filename.
To run java code >javac “filename.java”
To compile the code >java “filename”
Every line of code that runs in java must be inside a class.a class should
always start with a capital letter
every program must contain the main() method
each code statement must end with a semicolon ( ;).
Print methods:

System.out.print("Hello World! ");


System.out.println("This sentence will work!");

(prints in next line)


println() method to print numbers but we don't put numbers inside double
quotes and you can also perform mathematical calculations inside
the println() method
java comments:
single comments - // multilicommands - start with /* and ends with */
java variables :
String ,int,float,char,Boolean
To create a variable - syntax - type variablename=value;
Final variables: unchangeable or cannot be overridden final or constant
keyword is used
Printing variables :
String name=”john”;
System.out.println(“hello”+name);

Java uses the camel case. It is used as a naming convention for


variables, methods, and classes. It is a common convention in
many programming languages and involves writing the first word in
lowercase and subsequent words in uppercase, with no spaces or
underscores between the words

Data types in java:


1.primitive data types - most basic data types available within the Java language

Byte - Size: 8-bit Default value: 0 Range: -128 to 127

 Boolean - Size: 16-bit Default value: 0 Range: -32,768 to 32,767

 Char
 Short
 Int
 Long
 Float
 double
2.non primitive data type - defined by the programmer
Example: classes objects strings arrays interfaces etc
Type casting in java :
1 widening casting : when passing a smaller size type to a larger size type. Converting a small data
type to large datatype . it is done automatically by language
Example : assaigning an integer value to double value then the integer value is converted into
double value
Int num=9;
Double d= num;
2. Narrowing casting : bigger data type to smaller data type it should be done manually

Example : double myDouble = 9.78d;

int myInt = (int) myDouble

operators in java:
arthematic operators
logical operators : “&&”-logical and , “||”-logical or ,” ! ” – Logical not

STRINGS IN JAVA :

collection of characters surrounded by double quotes


string in java is an object
STRING METHODS IN JAVA :
STRING LENGTH:
String length- length() method
It is implemented in form of Object(string ).method()
Example:
String txt =”new string”
System.out.println(“length is “+txt.length());
STRING UPPERCASE:
String.toUppercase()
STRING LOWER CASE:
STRING.toLowercase();
indexOf method():
returns the index of a specified text in a string

charAt():returns the character at specified index


compareToIgnoreCase() : compare two strings lexicographically(alphabetical
order
compareTo() : compare two strings lexicographically(alphabetical order)
ignorinig case
concat():appends a string to the end of another string
contains():checks whether a string contains a sequence of charecters

You might also like