Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

Core Java

Rating
-
Sold
-
Pages
28
Uploaded on
07-05-2024
Written in
2023/2024

These notes on Core Java are a comprehensive guide for anyone seeking to learn the fundamentals of this powerful programming language. Written in a clear and concise manner, these notes cover all the essential topics required to build a strong foundation in Java programming, from basic syntax and data types to control statements, classes, objects, and inheritance. You'll learn how to work with arrays, interfaces, and exception handling, as well as how to develop multithreaded applications and use Java's powerful collection framework. These notes also provide useful tips, tricks, and examples to help you put your newfound knowledge into practice. Whether you're a beginner or an experienced programmer looking to brush up on your skills, these Core Java notes are an invaluable resource to have on hand.

Show more Read less
Institution
Course

Content preview

Core Java

,1. Give a brief History of Java.
Java was developed by James Gosling, who is known as the father of Java, in 1995. James Gosling and his team
members started the project in the early '90s. Currently, Java is used in internet programming, mobile devices, games,
e-business solutions, etc. The following are significant points that describe the history of Java. Initially, it was designed
for small, embedded systems in electronic appliances like set-top boxes. Firstly, it was called "Greentalk" by James
Gosling, and the file extension was .gt. After that, it was called Oak and was developed as part of the Green project. In
1995, Oak was renamed "Java" because it was already trademarked by Oak Technologies. Initially developed by James
Gosling at Sun Microsystems (which is now a subsidiary of Oracle Corporation) and released in 1995. Java is an island
in Indonesia where the first coffee was produced (called Java coffee). It is a kind of espresso bean. Java's name was
chosen by James Gosling while having a cup of coffee near his office.

2. Describe the Architecture of Java with components.
Java Development Kit is a core component of Java Environment and provides all tools, and executables required to
compile, debug, and execute Java Programs. JDK is platform-specific software and that’s why we have separate
installers for Windows, Mac, and Unix systems. We can say that JDK is a superset of JRE since it contains JRE with Java
compiler, debugger, and core classes. JRE (Java Runtime Environment) is a software package that provides Java class
libraries, Java Virtual Machine (JVM), and other components that are required to run Java applications. JRE is superset
of JVM. JVM is the heart of Java programming language. JVM is responsible for converting byte code to machine-
specific code. JVM is also platform-dependent and provides core Java functions such as memory management,
garbage collection, security, etc.

3. Explain the compilation process of Java.
When a Java program is executed, byte code is interpreted by JVM. But this interpretation is a slower process. To
overcome this difficulty, JRE includes a component JIT compiler. JIT makes execution faster. If the JIT Compiler library
exists, when particular bytecode is executed the first time, the JIT compiler compiles it into native machine code which
can be directly executed by the machine in which the Java program runs. Once byte code is recompiled by the JIT
compiler, the execution time needed will be much lesser. This compilation happens when byte code is about to be
executed hence the name “Just in Time”. Once bytecode is compiled into that particular machine code, it is cached
by the JIT compiler and will be reused for future needs. Hence main performance improvement by using the JIT
compiler can be seen when the same code is executed.

4. What are the salient features of Java?
Salient features of Java are as follows:
• Object Oriented: In Java, everything is an Object. Java can be easily extended since it is based on an Object model.
• Platform Independent: Java code can be run on any platform without writing code again and again
• Simple: Java is designed to be easy to learn.
• Secure: Java's secure feature, enables to development of virus-free, tamper-free systems.
• Architecture-neutral: Java compiler generates architecture-neutral object file format, making compiled code
executable on many processors, with Java runtime system.
• Portable: We can move class files from one platform to another platform and run it.
• Robust: Java makes an effort to eliminate error-prone situations by emphasizing mainly compile-time error
checking and runtime checking.
• Multithreaded: With Java's multithreaded feature it is possible to write programs that can perform many tasks
simultaneously.
• Interpreted: Java byte code is translated on the fly to native machine instructions and is not stored anywhere.
• High Performance: With the use of Just-In-Time compilers, Java enables high performance.
• Distributed: Java is designed for the distributed environment of the internet.
• Dynamic: Java is considered to be more dynamic than C or C++ since it is designed to adapt to evolving
environments.

5. Explain JDK
Java Development Kit is a core component of Java Environment and provides all tools, and executables required to
compile, debug, and execute Java Programs. JDK is platform-specific software and that’s why we have separate
installers for Windows, Mac, and Unix systems. We can say that JDK is a superset of JRE since it contains JRE with Java
compiler, debugger, and core classes.

, 6. Explain JRE
JRE (Java Runtime Environment) is a software package that provides Java class libraries, Java Virtual Machine (JVM),
and other components that are required to run Java applications. JRE is superset of JVM.

7. Explain JVM
JVM is the heart of Java programming language. JVM is responsible for converting byte code to machine-specific code.
JVM is also platform-dependent and provides core Java functions such as memory management, garbage collection,
security, etc.

8. Explain Data types in detail.
Data types in Java are as mentioned below:
• Boolean: Boolean data type represents only one bit of information either true or false. Values of type Boolean
are not converted implicitly or explicitly to any other type. But programmers can easily write conversion code.
• Byte: Byte data type is an 8-bit signed two’s complement integer. Byte data type is useful for saving memory in
large arrays. Size: 8-bit. Value: -128 to 127
• Short: Short data type is a 16-bit signed two’s complement integer. Similar to byte, use short to save memory in
large arrays, in situations where memory savings matters. Size: 16-bit. Value: -32,768 to 32,767
• Int: It is a 32-bit signed two’s complement integer. Size: 32-bit. Value: -231 to 231-1.
• Long: Long data type is a 64-bit two’s complement integer. Size: 64-bit. Value: -263 to 263-1.
• Float: Float data type is single-precision 32-bit IEEE 754 floating point. Use float if you need to save memory in
large arrays of floating point numbers. Size: 32 bits. Suffix: F/f. Example: 9.8f

9. Explain the program structure of Java with an example.
The program structure of Java consists of a set of components that define how Java program is written, compiled, and
executed. Components include:
• Package Declaration: This is an optional component that defines the package to which the Java file belongs. If
present, it is usually the first line in the Java program.
• Import Statement: This is another optional component that allows the programmer to import classes from other
packages into the current program. It follows package declaration and precedes class declaration.
• Class Declaration: This is the mandatory component that defines class and its properties. Java programs must
have at least one class declaration. The class declaration starts with the keyword "class" followed by the class
name, and a pair of curly braces that enclose the class body.
• Main Method: This is the mandatory component that is the entry point of the Java program. It is called by JVM
when the program is executed. The main method signature is: public static void main(String[] args)
• Program Statements: This component contains actual code that the program executes. It is enclosed in curly
braces that follow the main method signature.
Example:
import java.util.Scanner;
public class ExampleProgram {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter your name: ");
String name = scanner.nextLine();
System.out.println("Hello, " + name + "!");
}
}
In this example, the program starts with the package declaration "package com.example;", followed by an import
statement that imports the Scanner class from java.util package. The class declaration starts with the keyword "class"
followed by the class name "ExampleProgram", and the class body is enclosed in curly braces. The main method is
declared with the signature "public static void main(String[] args)", and it contains program statements that prompt
users for their name, read input using the Scanner class, and then print out the greeting. This is a simple example that
demonstrates the basic program structure of Java program.

Written for

Institution
Course

Document information

Uploaded on
May 7, 2024
Number of pages
28
Written in
2023/2024
Type
Class notes
Professor(s)
Dr. bhakti
Contains
All classes

Subjects

$3.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
sushanttare

Also available in package deal

Get to know the seller

Seller avatar
sushanttare University of Mumbai
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
2 year
Number of followers
0
Documents
7
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions