Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 4

Article writing on - "Java".

-------------------------------------------------------------------------------

In the era of coding and programming where Hindi and English languages are no more
enough to communicate with a machine ,
hence was introduced the concept of programs and machine learning.

Computer programming is important today because so much of our world is automated.


Humans need to be able to control the interaction between people and machines.

Since computers and machines are able to do things so efficiently and accurately,
we use computer programming to harness that computing power...
________________________________________________________________________________

The Java programming language was developed by Sun Microsystems in the early 1990s.

Although it is primarily used for Internet-based applications, Java is a simple,


efficient, general-purpose language.
Java was originally designed for embedded network applications running on multiple
platforms.
It is a portable, object-oriented, interpreted language.

Simple Hello World Program :

//
A Java program to print "Hello World"

public class GFG


{

public static void main(String args[])

System.out.println("Hello World");

}
}

Output :
Hello World

___________________________________________________________________________________
____________

Java is extremely portable. The same Java application will run identically on any
computer, regardless of hardware features or operating system, as long as it has a
Java interpreter.
Besides portability, another of Java's key advantages is its set of security
features which protect a PC running a Java program not only from problems caused by
erroneous code but also from malicious programs (such as viruses).
You can safely run a Java applet downloaded from the Internet, because Java's
security features prevent these types of applets from accessing a PC's hard drive
or network connections.
An applet is typically a small Java program that is embedded within an HTML page.
Java is a dynamic language where you can safely modify a program while it is
running, whereas C++ does not allow it.
This is especially important for network applications that cannot afford any
downtime.
Also, all basic Java data types are predefined and not platform-dependent, whereas
some data types can change with the platform used in C or C++ (such as the int
type).
Another key feature of Java is that it is an open standard with publicly available
source code.
___________________________________________________________________________________
_____________

When the constructor of a class is invoked?

Ans: The constructor of a class is invoked every time an object is created with new
keyword.

For example, in the following class two objects are created using new keyword and
hence, constructor is invoked two times.

public class const_example


{

const_example()
{

system.out.println("Inside constructor");

public static void main(String args[])


{

const_example c1 = new const_example();

const_example c2 = new const_example();

}
___________________________________________________________________________________
__________

How can an exception be thrown manually by a programmer?

Ans: In order to throw an exception in a block of code manually, throw keyword is


used.
Then this exception is caught and handled in the catch block.
public void topMethod() {

try {

excMethod();

}
catch (ManualException e) {}
}
public void excMethod {

String name = null;

if (name == null) {

throw (new ManualException("Exception thrown manually ");

___________________________________________________________________________________
___________

The basic requirement of method overriding in Java is that the overridden method
should have same name,
and parameters.But a method can be overridden with a different return type as long
as the new return type extends
the original.

For example , method is returning a reference type.

Class B extends A
{

A method(int x){

//original method

B method(int x)
{

//overridden method

}
___________________________________________________________________________________
_________________

Data structures and algorithms in Java Collections:


The Java Collections Framework supports many kinds of container-oriented data
structures and associated algorithms.
This series will help you better understand this framework.
Design patterns and data structures:
It's become fairly common to use design patterns to introduce university students
to data structures.
A Brown University paper surveys several design patterns that are useful for
designing high-quality data structures.
Among other things, the paper demonstrates that the Adapter pattern is useful for
designing stacks and queues.
Why Java is Preferred over other Programming Languages?

The best thing about Java is that it is machine independent and can be written once
and run anywhere.
Furthermore, Java is a statically typed programming language that makes it faster
than other languages.
Java considers security as part of its design...

You might also like