Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
13 views25 pages

Nishanth Report 1

This report details an internship conducted by Nishanth V at Don Bosco Institute of Technology, focusing on the Java programming language. It covers various aspects of Java, including its architecture, features, and comparisons with other programming languages like Python, C++, and C. The document serves as a partial fulfillment for the Bachelor of Engineering in Computer Science Engineering at Visvesvaraya Technological University.
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)
13 views25 pages

Nishanth Report 1

This report details an internship conducted by Nishanth V at Don Bosco Institute of Technology, focusing on the Java programming language. It covers various aspects of Java, including its architecture, features, and comparisons with other programming languages like Python, C++, and C. The document serves as a partial fulfillment for the Bachelor of Engineering in Computer Science Engineering at Visvesvaraya Technological University.
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/ 25

1

VISVESVARAYA TECHNOLOGICAL UNIVERSITY


JNANA SANGAMA, BELGAVI-590018

A Report on
Inter/Intra-institutional Internship (Course Code: 21INT49)

Carried out at
DON BOSCO INSTITUTE OF TECHNOLOGY
BENGALURU - 560074
Submitted in partial fulfilment for

Bachelor of Engineering
In
Computer Science Engineering

Submitted by

Nishanth v 1DB21CS097

Under the Guidance of


Mrs Thaseen taj
Associate Professor
Department of Computer Science Engineering
Don Bosco Institute of Technology

Department of Computer Science Engineering


Don Bosco Institute of Technology
Kumbalagodu, Mysore Road, Bangalore-560 074
2020-2021

1|Page
2

DON BOSCO INSTITUTE OF TECHNOLOGY


Kumbalagodu, Mysore Road, Bangalore-560 074

DEPARTMENT OF COMPUTER SCIENCE ENGINEERING

CERTIFICATE

Certified that the Inter/Intra-institutional Internship (Course Code: 21INT49) work


carried out by Nishanth v(1DB21CS097) is a bona fide work carried out at Don Bosco
Institute of Technology, in partial fulfilment for the award Bachelor of Engineering in
Computer Science Engineering of Visvesvaraya Technological University, Belgavi, during
academic year 2022-2023. It is certified that all corrections/suggestions indicated for Internal
Assessment have been incorporated in the report deposited in the departmental library. The
Internship report has been approved as it satisfies the academic requirements in respect of the
work prescribed for the said degree.

Internship Mentor Professor and Head Principal

2|Page
Content

Title Pg No

What is JAVA? 4-5


and a brief introduction to the JAVA
JAVA Working 6
Differences of Java from other programming 7-8
language
Java Architecture 9
Difference between JDK , JRE , JVM 10-12
Understanding the Byte code and Machine 13-14
code
Concept of Object Orientation in the Java 15-17
language
Method overloading and method overriding in 18-19
the Java
Keywords and Packages in Java 20-21

Condition Statements in Java 22-25

3|Page
WHAT IS JAVA?
Java is a popular programming language, created in 1995.

It is owned by Oracle, and more than 3 billion devices run


Java.

It is used for:

 Mobile applications (specially Android apps)


 Desktop applications
 Web applications
 Web servers and application servers
 Games
 Database connection
 And much, much more!

Why Use Java?

 Java works on different platforms (Windows, Mac, Linux,


Raspberry Pi, etc.)
 It is one of the most popular programming language 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 a 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

4|Page
WHAT IS JAVA PLATFORM?
Java Platform is a collection of programs that help programmers to
develop and run Java programming applications efficiently. It includes an
execution engine, a compiler, and a set of libraries in it.

It is a set of computer software and specifications. James Gosling


developed the Java platform at Sun Microsystems, and the Oracle
Corporation later acquired it.

Java is a multi-platform, object-oriented, and network-centric language. It is


among the most used programming language. Java is also used as a
computing platform.

It is considered as one of the fast, secure, and reliable programming


languages preferred by most organizations to build their projects.

Java Features
Here are some important Java features:

 It is one of the easy-to-use programming languages to learn.


 Write code once and run it on almost any computing platform.
 Java is platform-independent. Some programs developed in one
machine can be executed in another machine.
 It is designed for building object-oriented applications.
 It is a multithreaded language with automatic memory
management.
 It is created for the distributed environment of the Internet.
 Facilitates distributed computing as its network-centric.

Components of Java Programming Language


A Java Programmer writes a program in a human-readable language called
Source Code. Therefore, the CPU or Chips never understand the source
code written in any programming language.

These computers or chips understand only one thing, which is called


machine language or code. These machine codes run at the CPU level.
Therefore, it would be different machine codes for other models of CPU.

5|Page
JAVA WORKING

Java is a high-level language, which represents logical


computer concepts in a fashion that is easier for humans to
understand than low-level machine code or assembly
language. However, this means that in order to run on a
machine, the code must be compiled into machine code or
interpreted by a special-purpose machine.
One design goal of Java is portability, which means that
programs written for the Java platform must run similarly on any
combination of hardware and operating system with adequate
run time support.
This is achieved by compiling the Java language code to an
intermediate representation called Java byte code, instead of
directly to architecture-specific machine code. Java byte code
instructions are analogous to machine code, but they are
intended to be executed by a virtual machine written specifically
for the host hardware. End-users commonly use a Java.
Runtime Environment installed on their device for standalone
Java applications or a web browser for Java applets.
Standard libraries provide a generic way to access host-specific
features such as graphics, threading and networking.
The use of universal byte code makes porting simple. However,
the overhead of interpreting byte code into machine instructions
made interpreted programs almost always run more slowly than
native executables.
Just-in-time compilers that compile byte-codes to machine code
during runtime were introduced from an early stage. Java's
Hotspot compiler is actually two compilers in one; and
with GraalVM allowing tiered compilation Java is platform-
independent and is adapted to the particular platform it is to run
on by a Java virtual machine for it, which translates the Java
byte code into the platform's machine language.

6|Page
Differences of JAVA form other programming
languages

Java is one of the most popular and widely used programming


language and platform. 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.
Here we are comparing 3 other languages (Python, C++ and C) with
Java.

PYTHON
 Python is a high-level language. It fully supports object-oriented
programming. Python is not a pure object-oriented language.
 Python is an interpreted language whereas Java is not an
interpreted language, it is a compiled language.
 Python is a scripting language whereas JAVA is a low-level
implementation language.
 Python is easy to use whereas JAVA is not as simple as Python.
Programmers prefer to use python instead of Java because python
contains less line of code whereas Java is just opposite to it.
 Python programs are much shorter than JAVA programs.
 Python is widely used in companies for building projects as its
programs are shorter whereas JAVA is rarely used in companies for
projects because it is difficult to use.
 Python supports dynamic typing which is very useful for the
programmers because they need to write less code because of
which their time is saved and which is user-friendly as well as
programmer-friendly. But in the case of JAVA, developers are
required to define the type of each variable before using it which
consumes the programmer’s lots of time.
 Many large organizations like Google, Yahoo, NASA, etc. are
making use of Python. But Python programs are generally expected
to run slower than Java programs.
 Java has much better library support for some use cases than
Python which is the biggest advantage of JAVA.
 Python is very much slower than Java.

7|Page
C++

 Java was basically derived from C++.


 C++ is both procedural and object-oriented programming language
whereas Java is a pure object-oriented language.
 Both the languages have different objectives which mean it has
many differences too.
 The main objective of C++ is to design a system of programming.
 Java doesn’t support operator overloading but C++ does support it.
 C++ also extends the C programming language whereas Java is
basically created to support network computing.
 Java doesn’t support structures and unions where C++ does support
it.
 Java is much slower than C++ in terms of execution.
 C++ libraries are simple and also they are robust. It also provides
container and associative arrays. But Java contains a powerful
cross-platform library.
 In Java, there is an automatic garbage collection whereas this is not
the case in C++. In C++ all objects are destroyed manually with the
help of the code.
 C++ supports pointers which are variables which store addresses of
other variables. But Java does not have any kind of variable which
stores addresses of other variables.
 C++ executes its programs very fast compared to Java.

C
 C is very much like C++ (which was used to derive Java). In fact, C+
+ is an updated form of C.
 C is a structure or procedure-oriented language whereas Java is an
object-oriented programming language.
 Execution time for programs written in C is very less when compared
to Java.
 C supports pointers whereas Java does not support variables for
storing addresses of other variables.
 C cannot handle exceptions in its program whereas Java is very
good at handling exceptions.

8|Page
JAVA ARCHITECTURE

Java Architecture is a collection of components, i.e., JVM,


JRE, and JDK. It integrates the process of interpretation and
compilation. It defines all the processes involved in creating a
Java program. Java Architecture explains each and every step
of how a program is compiled and executed.

The following figure represents the Java Architecture in which


each step is elaborate graphically.

Components of Java Architecture


The Java architecture includes the three main components:

o Java Virtual Machine (JVM)


o Java Runtime Environment (JRE)
o Java Development Kit (JDK)

9|Page
Difference between JDK, JRE, JVM
JVM – JAVA VIRTUAL MACHINE
JVM (Java Virtual Machine) is an abstract machine. It is called a
virtual machine because it doesn't physically exist. It is a
specification that provides a runtime environment in which Java
byte code can be executed. It can also run those programs
which are written in other languages and compiled to Java byte
code.

JVMs are available for many hardware and software platforms.


JVM, JRE, and JDK are platform dependent because the
configuration of each OS is different from each other. However,
Java is platform independent. There are three notions of the
JVM: specification, implementation, and instance.

The JVM performs the following main tasks:

o Loads code
o Verifies code
o Executes code
o Provides runtime environment

10 | P a g e
JRE – JAVA RUNTIME ENVIRONMENT

JRE is an acronym for Java Runtime Environment. It is also


written as Java RTE. The Java Runtime Environment is a set of
software tools which are used for developing Java applications.
It is used to provide the runtime environment. It is the
implementation of JVM. It physically exists. It contains a set of
libraries + other files that JVM uses at runtime.

A Java runtime environment runs on top of the OS and provides


additional Java-specific resources. It abstracts the OS and
creates a consistent platform on which to run and deploy Java
applications. The 3 components of the JRE work together within
this environment to successfully run a Java application.

The Java class libraries contain collections of prewritten code


that can be called when needed. The class loader connects
class libraries with the JVM and loads them into the JVM while
the program is running. The JVM then executes the code.

11 | P a g e
JDK – Java Development Kit

JDK is an acronym for Java Development Kit. The Java


Development Kit (JDK) is a software development environment
which is used to develop Java applications and applets. It
physically exists. It contains JRE + development tools.

JDK is an implementation of any one of the below given Java


Platforms released by Oracle Corporation:

o Standard Edition Java Platform


o Enterprise Edition Java Platform
o Micro Edition Java Platform

The JDK contains a private Java Virtual Machine (JVM) and a few
other resources such as an interpreter/loader (java), a compiler,
an archive, a documentation generator, etc. to complete the
development of a Java Application.

12 | P a g e
Introduction about Byte code and Machine code

Byte code is an intermediate code between the source code


and machine code. It is a low-level code that is the result of
the compilation of a source code which is written in a high-
level language. It is processed by a virtual machine like Java
Virtual Machine.

Byte code is a non-run able code after it is translated by an


interpreter into machine code then it is understandable by the
machine. It is compiled to run on JVM, any system having JVM
can run it irrespective of their operating system. That’s why
Java is platform-independent. Byte code is referred to as a
Portable code.
Machine code is a set of instructions that is directly machine-
understandable and it is processed by the Central Processing
Unit (CPU). Machine code is in binary (0’s and 1’s) format
which is completely different from the byte code and source
code. It is regarded as the most lowest-level representation of
the source code. Machine code is obtained after compilation or
interpretation. It is also called machine language.

13 | P a g e
Difference between Byte code and machine code

Byte code Machine code

1. Byte code consisting of 1. Machine code consisting of


binary hexadecimal, macro binary instructions is directly
instructions like (new, add, understandable by the CPU.
swap, etc) and it is not directly
understandable by the CPU.

2. Byte code is considered as the 2. Machine Code is considered as the


intermediate-level code. low-level code.

3. Byte code is executed by the virtual 3. Machine code is not executed by a


machine then the Central Processing virtual machine it is directly executed by
Unit. CPU.

4. It is platform-independent as it is 4. It is not platform independent


dependent on the virtual machine and because the object code of one
the system having a virtual machine platform can not be run on the same
can be executed irrespective of the Operating System. Object varies
platform. depending upon system architecture
and native instructions associated with
the machine

5. Byte code is less specific 5. Machine code is more


towards machine than machine specific towards machine than
code. byte code.

6. Byte code is a non-run able code 6. Machine code is a set of


generated after compilation of source instructions in machine language or in
code and it relies on an interpreter to binary format and it is directly executed
get executed. by CPU.
.

14 | P a g e
OOP concept in JAVA Language

Object-Oriented Programming is a paradigm that provides


many concepts, such as inheritance, data
binding, polymorphism, etc.

Simula is considered the first object-oriented programming


language. The programming paradigm where everything is
represented as an object is known as a truly object-oriented
programming language.

Smalltalk is considered the first truly object-oriented


programming language.

The popular object-oriented languages


are Java, C#, PHP, Python, C++, etc.

OOPs (Object-Oriented Programming System)


Object means a real-world entity such as a pen, chair, table, computer,
watch, etc. Object-Oriented Programming is a methodology or paradigm
to design a program using classes and objects. It simplifies software
development and maintenance by providing some concepts:

o Object
o Class
o Inheritance
o Polymorphism
o Abstraction
o Encapsulation

Apart from these concepts, there are some other terms which are used in
Object-Oriented design:

o Coupling
o Cohesion
o Association
o Aggregation
o Composition

15 | P a g e
Object:
Any entity that has state and behavior is known as an object.
For example, a chair, pen, table, keyboard, bike, etc. It can be
physical or logical.

An Object can be defined as an instance of a class. An object


contains an address and takes up some space in memory.
Objects can communicate without knowing the details of each
other's data or code. The only necessary thing is the type of
message accepted and the type of response returned by the
objects.

Class:
Collection of objects is called class. It is a logical entity.

A class can also be defined as a blueprint from which you can


create an individual object. Class doesn't consume any space.

Inheritance:
When one object acquires all the properties and behaviors of a
parent object, it is known as inheritance. It provides code
reusability. It is used to achieve runtime polymorphism.

Polymorphism:

16 | P a g e
If one task is performed in different ways, it is known as
polymorphism. For example: to convince the customer
differently, to draw something, for example, shape, triangle,
rectangle, etc.

In Java, we use method overloading and method overriding to


achieve polymorphism.

Another example can be to speak something; for example, a


cat speaks meow, dog barks woof, etc.

Abstraction:
Hiding internal details and showing functionality is known as
abstraction. For example phone call, we don't know the internal
processing.

Encapsulation:
Binding (or wrapping) code and data together into a single unit
are known as encapsulation. For example, a capsule, it is
wrapped with different medicines.

A java class is the example of encapsulation. Java bean is the


fully encapsulated class because all the data members are
private here.

Method:
The method in Java is a collection of instructions that performs
a specific task. It provides the reusability of code. We can also
easily modify code using methods. A method is a block of code
or collection of statements or a set of code grouped together to
perform a certain task or operation. It is used to achieve
the reusability of code. We write a method once and use it
many times. We do not require writing code again and again. It
also provides the easy modification and readability of code, just
by adding or removing a chunk of code. The method is
executed only when we call or invoke it.

17 | P a g e
Concepts of Method overloading and
Method overriding:
Method overloading:
 Method overloading is a compile-time polymorphism.
 It helps to increase the readability of the program.
 It occurs within the class.
 Method overloading may or may not require inheritance.
 In method overloading, methods must have the same
name and different signatures.
 In method overloading the return type can or cannot be
the same, but we just have to change the parameter.
 Static binding is being used for overloaded methods
 Private and final methods can be overloaded.
 Poor performance due to complete time polymorphism.
 Arguments list should be different while doing method
overloading.

import java.io.*;
class MethodOverloadingEx {
static int add(int a, int b)
{
return a + b;
}
static int add(int a, int b, int c)
{
return a + b+ c;
}
public static void main (string args[ ])
{
System.out.println(“add() with 2 parameters “);
System.out.println(add(4,6));
System.out.println(“add() with 3 parameters “);
System.out.println(add(4,6,7);

18 | P a g e
}
}

Method overriding:
 Method overriding is a run-time polymorphism.
 It is performed in two classes with inheritance relationships.
 In method overriding, methods must have the same name and
same signature.
 Dynamic binding is being used for overriding methods.
 Private and final methods can’t be overridden.
 Arguments list should be same in method overloading.
 It gives better performance. The reason behind this is that the
binding of overridden methods is being done at runtime.
 In method overriding, the return type must be the same or co-
variant.
 Method overriding always needs inheritance.
 It is used to grant the specific implementation of the method
which is already provided by its parent class or superclass.

import java.io.*;
class Animal {
void eat ()
{
System.out.println(“eat() method of base class “);
System.out.println (“eating.”);
}
}
class Dog extends Animal {
void eat()
{
System.out.println(“ eat() method of derived class “);
System.out.println (“Dog is eating. “);
}
}
Class MethodOverloadingEx {
public static void main (String args[ ])
{
Dog d1 = new Dog();
Animal a1 = new Animal ();

d1.eat();
a1.eat();

Animal animal = new Dog();


// eat () method of animal class is overridden by
// base class eat ()
animal.eat();
}
}

19 | P a g e
Keywords and packages in java:
In the Java programming language, a keyword is any one of 67 reserved
words that have a predefined meaning in the language. Because of this,
programmers cannot use keywords in some contexts, such as names
for variables, methods, classes, or as any other identifier of these 67
keywords, 16 of them are only contextually reserved, and can
sometimes be used as an identifier, unlike standard reserved words.
Due to their special functions in the language, most integrated
development environments for Java use syntax highlighting to display
keywords in a different colour for easy identification.

List of java keywords:

 abstract  final  if
 case  do  interface
 continue  char  private
 enum  boolean  static
 for  try  this
 instanceof  synchronized  void
 new  short  break
 return  package  class
 switch  int  double
 transient  goto  long
 assert  extends  public
 catch  default  protected

Packages in the java:


A java package is a group of similar types of classes, interfaces and sub-
packages.

Package in java can be categorized in two form, built-in package and user-
defined package.

There are many built-in packages such as java, lang, awt, javax, swing,
net, io, util, sql etc.

20 | P a g e
Advantage of Java Package

1) Java package is used to categorize the classes and interfaces so that


they can be easily maintained.

2) Java package provides access protection.

3) Java package removes naming collision.

Simple example for package

package mypack;
public class Simple{
public static void main(String args[ ]){
System.out.println("Welcome to package");
}
}
Condition control statements in JAVA:
1) Condition control statements

21 | P a g e
a) If statement
b) If-else statement
c) If-else-if statement
d) Switch statement
2) Looping control statements
a) For loop
b) While loop
c) Do-while loop
3) Unconditional control statements / jump statements
a) Break statement
b) Continue statement

If statement

It will go inside the block only if the condition is true otherwise, it will not execute the
block.
if(condition){
// statements (if Block)
}
//other statements

If-Else Statement

If the condition is true then, it will execute the If block. Otherwise, it will execute the
Else block.
if(condition){
// statements (if Block)
}
else{
// statements (Else block)
}
//other statements

22 | P a g e
If-Else-If statement

If the condition is true, then it will execute the If block. Otherwise, it will execute the
Else-If block. Again, if the condition is not met, then it will move to the else block.
if(condition){
// statements (if Block)
}
else if{
// statements (Else-If block)
}
else{
//statements(Else Block)
}//other statements

Switch Statement

Switch statement allows program to select one among multiple actions during
program execution.

Syntax:
Switch(variable/value/expression){
Case :
// statements [];
Case :
// statements [];

default:
// statements [];
}s

23 | P a g e
For loop

 It executes the code until condition is false.


 It is used when number of iterations are known.

Syntax:
for(initialization; condition; increment/decrement){
//statements (For Body)
}

While loop

 While loop executes till the condition becomes false.

Syntax:
while(condition){
// statements
}

Do-while loop

 When you are using for or while, then it will execute the loop body only if the
condition if true.
 In do-while loop, it will execute the loop first, then it checks the condition. So, it
will execute the loop at least once.

Syntax:
do{
// statements
}while(condition);

24 | P a g e
Break Statement

 break is a keyword. It is used within any control statements. It is used to terminate the
execution of the current loop or switch statements.
 Syntax: break; or break <label>;

Continue Statement

 continue is a keyword. It is used to continue the execution of the current loop with the
next iteration.
 Syntax: continue; or continue<label>;

-------------------THE END-------------------

25 | P a g e

You might also like