Problems of Java
Problems of Java
First Paper
KRISHNENDU MITRA
( Fullstack Web Developer )
Introduction:
Java is a high-level, object-oriented, and platform-independent programming language. It was
developed by James Gosling and his team at Sun Microsystems (now owned by Oracle Corporation) in
the mid-1990s. Java quickly gained popularity due to its "Write Once, Run Anywhere" (WORA)
capability, which allows Java programs to be executed on any platform with a Java Virtual Machine
(JVM).
2. Platform Independence: Java achieves platform independence by compiling Java source code into
an intermediate form called bytecode. This bytecode can run on any platform with a JVM, making
Java applications highly portable.
3. Memory Management: Java manages memory automatically through a process known as garbage
collection. This reduces the burden on the programmer, as they don't need to manually allocate
or deallocate memory.
4. Robustness and Safety: Java is designed to be robust and safe. It includes features like strong
type-checking, exception handling, and runtime bounds checking to ensure stable and secure
program execution.
5. Multi-threading Support: Java has built-in support for multi-threading, allowing developers to
create concurrent applications. This is essential for tasks like handling multiple client requests in
server-side applications.
6. Rich Standard Library: Java comes with a vast standard library that provides a wide range of pre-
built classes and packages, making it easier for developers to accomplish various tasks without
having to write everything from scratch.
7. Community and Ecosystem: Java has a massive and active developer community, resulting in a
rich ecosystem of libraries, frameworks, and tools that enhance productivity and help developers
build complex applications more efficiently.
Applications of Java:
Java is used in a wide range of applications, including but not limited to:
o Web development: Java serves as the backbone for many server-side web applications and
enterprise-level systems.
o Enterprise applications: Java is well-suited for building large-scale, robust, and secure enterprise-
level applications.
o Scientific applications: Java is used in scientific and research-oriented applications due to its
performance and numerical computation capabilities.
Overall, Java's popularity can be attributed to its simplicity, portability, robustness, and
versatility. Its widespread use in various domains makes it a valuable skill for programmers and
ensures its relevance in the software development landscape.
Determining whether Java is better than C or Python depends on the context and the specific
requirements of a project. Each language has its strengths and weaknesses, and the choice of language
often depends on the nature of the application and the goals of the development.
1. Platform Independence: Java's "Write Once, Run Anywhere" capability allows it to run on any
platform with a Java Virtual Machine (JVM). In contrast, C code needs to be compiled separately
for each target platform.
2. Automatic Memory Management: Java's garbage collection takes care of memory management,
reducing the risk of memory leaks and making it easier for developers to manage memory
compared to C, where manual memory allocation and deallocation can be error-prone.
3. Object-Oriented: Java is inherently object-oriented, making it easier to design and organize code
using classes and objects, leading to code reusability and easier maintenance.
4. Rich Standard Library: Java comes with an extensive standard library, providing numerous pre-
built classes and functions for common tasks, which can save development time.
1. Performance: Java generally performs better than Python for computationally-intensive tasks due
to its compiled nature and static typing. Python, being an interpreted language, can be slower in
certain scenarios.
2. Strong Typing: Java enforces strong typing, which helps catch errors at compile time, reducing the
likelihood of runtime errors compared to Python's dynamic typing.
3. Threading: Java has better support for multithreading and concurrent programming, making it
more suitable for applications requiring heavy parallel processing.
It's important to note that C and Python have their own advantages in different contexts:
o Python's extensive libraries and frameworks support various domains, such as web development
(Django, Flask), scientific computing (NumPy, SciPy), and data analysis (Pandas).
Installation of JAVA:
Pre-requiring Java
Before starting Modern Java problem solving some important installations and setup is
required in our computer. The first one is checking your
computer is ready to handling Java codes or not. Check the
storge is at least 45% clear and processor is higher than {i3,
ryzen3, dimensity 900, snapdragon 695} processor. If this
point is clear then ready to install programming environment
in our computer. At first download an IDE like VS-code, Java,
CodeBlockes etc. I am using VS-code to implement Java codes
for this paper.
1. Vs Code installations:
For more details to install Vs-code visit my youtube channel where I guide how to install it
step by step.
2. Make a Folder:
After installation Vs-code ide, you need a folder where you store your all Java codes and its
related media. This folder make your Os UI clean and logical so open your vs code folder or
follow this path to make a folder there ‘ D:\.vscode\Vs programmes\ ’(same path is not
required) , make folder name ‘ Java codes ’ like following
Post-requiring Java
When the pre-requiring points is done and your computer ready to approach java then simply
install Java on your computer, follow these steps based on windows operating system:
I. Visit the Oracle website to download the Java Development Kit (JDK) or the Java Runtime
Environment (JRE). The JDK includes the JRE and additional development tools, so it's usually
recommended for developers.
III. Accept the license agreement and choose the appropriate JDK or JRE version for your
operating system (e.g., Windows x64 for 64-bit Windows or Windows x86 for 32-bit Windows).
V. After installation, set the "JAVA_HOME" environment variable to point to the JDK installation
directory and add the "bin" directory to the "PATH" environment variable.
VI. To verify that Java is installed, open a command prompt and type `java -version` to see the
installed Java version.
>> Note that if you want you use java in only VS-code then follow the given points:
I. Visit the Microsoft OpenJDK website to download the Java Development Kit (JDK). Click
the download button and go to next page. Showing at below,
II. Download the windows OpenJDK package in your computer supporting system in terms
of 32bit/64bit/128bit/etc.. and wait to download.
III. When download is completed, run it as administrator in your computer and accept the
license agreement (Read first).
IV. After installation, set the "JAVA_HOME" environment variable to point to the JDK
installation directory and add the "bin" directory to the "PATH" environment variable.
V. To verify that Java is installed, open a Terminal in your selected folder in VS-code and type
` java --version ` to see the installed Java version.
Open “Java codes” folder in Vs-code and make file which name is ‘Main.java’ and write the given codes
and run it in terminal. In terminal write javac Main.java and wait compile it, this command make a
class file named ‘Main.class’ and then write java Main in terminal and wait to get output
If you want to learn more and depley about java then download our another java ebooks in following
sourse and read them , this doument’s Aim only solve some Java related problems.
More source is:
https://whitelotus4.github.io/weatherbyWHITELOTUS.github.io/PStorebyWhiteLotus.html#PS
WL1?details=Problems%20of%20Java.kid
Visit this site and search there introduction of java or simply java.
Check out the Licence and meta data for this document to understand this paper.
The given all code and ther output is follow the makaut universty syllabus and programe related
curiculam on colleges, this paper based on 2017 to 2024s Java language and Java libraries.
1 4 9 16 25 36 49 64 81 100
import java.util.Scanner;
//code by krish
public class Main{
public static void main(String args[]){
//not return anything
int i, term, n;
//access scanner utility
Scanner input = new Scanner(System.in);
System.out.print("Enter the range of number(n): ");
n = input.nextInt(); //take user input
//0 to n do
for(i = 0; i < n; i++){
1 2 4 7 11 16 22 29 37 46 56 67 79 92 106
2) Write a program to input an integer and check whether it is a prime number or not:
import java.util.Scanner;
//code by krish
public class Main{
public static void main(String args[]){
//not return anything
int i, n, temp = 0;
//access scanner utility
Scanner input = new Scanner(System.in);
System.out.print("Enter the number: ");
n = input.nextInt(); //take user input
//0 or 1 not prime and unloopable
if(n == 0 || n == 1){
System.out.println(n + " is not prime number");
}else{
for(i = 2; i < n; i++){ //never i<=n, always i<n
if(n % i == 0){ //reminder 0 says it is not
System.out.println(n + " is not prime number");
temp++; //how many elements able to encounter n
//break the code
break;
}
17 is prime number
import java.util.Scanner;
//code by krish
public class test{
public static void main(String args[]){
//not return anything
int i, n;
//access scanner utility
Scanner input = new Scanner(System.in);
System.out.print("Enter the number: ");
n = input.nextInt(); //take user input
//huge size factorial value store in long
long fact = 1;
for(i = 1; i <= n; ++i){
// x! = x * (x-1) * (x-2) *.....* 2 * 1;
fact *= i;
}
System.out.printf("Factorial of %d = %d ", n, fact);
input.close(); //close the scanner utility
}
}
Factorial of 5 = 120
1 2 5 12 29
5) Using nested loops write programmes to generate the following patterns on the screen :
a.
*****
****
***
**
*
public class Main{
//code by krish
public static void main(String[] args){
int n = 5; //row no is given in question
int i, j; //loop controller
for(i = n; i > 0; i--){
//no space requires
for(j = 1; j <= i; j++){ //loop in a loop
System.out.print("*");
}
System.out.println();
}
}
}
Output:
*****
****
***
**
12345
23451
34512
45123
51234
23451
34512
45123
51234
To be continue…..