JAVA Unit 1 !!

1. Highlight the features of Java , elaborating its application and importance.
	Java is a general-purpose programming language that is class-based, object-oriented and designed to have as few implementation dependencies as possible. It is intended to let application developers write once, run anywhere (WORA), meaning that compiled Java code can run on all platforms that support Java without the need for recompilation.Java is a high level, robust, object-oriented and secure programming language.

There are 4 platforms or editions of Java:
1) Java SE (Java Standard Edition)
It is a Java programming platform. It includes Java programming APIs such as java.lang,,, java.util, java.sql, java.math etc. It includes core topics like OOPs, String, Regex, Exception, Inner classes, Multithreading, I/O Stream, Networking, AWT, Swing, Reflection, Collection, etc.
2) Java EE (Java Enterprise Edition)
It is an enterprise platform which is mainly used to develop web and enterprise applications. It is built on the top of the Java SE platform. It includes topics like Servlet, JSP, Web Services, EJB, JPA, etc.
3) Java ME (Java Micro Edition)
It is a micro platform which is mainly used to develop mobile applications.
4) JavaFX
It is used to develop rich internet applications. It uses a light-weight user interface API.

2. Elaborate usage and importance of Java , highlighting its applications as well
	Java is a popular programming language, created in 1995.
Java is used for:

1. Mobile applications (specially Android apps)
2. Desktop applications
3. Web applications
4. Web servers and application servers
5. Games
6. Database connection

Applications : 
Java works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc.)
1. It is one of the most popular programming language in the world
2. It is easy to learn and simple to use
3. It is open-source and free
4. It is secure, fast and powerful
5. It has a huge community support (tens of millions of developers)

3. Elaborate the difference between Language C and Java
	Java VS C 
1. JAVA is Object-Oriented while C is procedural. Different Paradigms, that is.
Most differences between the features of the two languages arise due to the use of different programming paradigms. C breaks down to functions while JAVA breaks down to Objects. C is more procedure-oriented while JAVA is data-oriented.

2. Java is an Interpreted language while C is a compiled language.
We all know what a compiler does. It takes your code & translates it into something the machine can understand-that is to say-0’s & 1’s-the machine-level code. That’s exactly what happens with our C code-it gets ‘compiled’. While with JAVA, the code is first transformed to what is called the bytecode. This bytecode is then executed by the JVM(Java Virtual Machine). For the same reason, JAVA code is more portable.

3. C is a low-level language while JAVA is a high-level language.
C is a low-level language(difficult interpretation for the user, closer significance to the machine-level code) while JAVA is a high-level language (abstracted from the machine-level details, closer significance to the program itself).

4. C uses the top-down {sharp & smooth} approach while JAVA uses the bottom-up {on the rocks} approach.
In C, formulating the program begins by defining the whole and then splitting them into smaller elements. JAVA(and C++ and other OOP languages) follows the bottom-up approach where the smaller elements combine together to form the whole.

5. Pointer go backstage in JAVA while C requires explicit handling of pointers.
When it comes to JAVA, we don’t need the *’s & &’s to deal with pointers & their addressing. More formally, there is no pointer syntax required in JAVA. It does what it needs to do. While in JAVA, we do create references for objects.

6. The Behind-the-scenes Memory Management with JAVA & The User-Based Memory Management in C.
Remember ‘malloc’ & ‘free’? Those are the library calls used in C to allocate & free chunks of memory for specific data(specified using the keyword ‘sizeof’). Hence in C, the memory is managed by the user while JAVA uses a garbage collector that deletes the objects that no longer have any references to them.

7. JAVA supports Method Overloading while C does not support overloading at all.

JAVA supports function or method overloading-that is we can have two or more functions with the same name(with certain varying parameters like return types to allow the machine to differentiate between them). That it to say, we can overload methods with the same name having different method signatures. JAVA(unlike C++), does not support Operator Overloading while C does not allow overloading at all.

8. Unlike C, JAVA does not support Preprocessors, & does not really them.
The preprocessor directives like #include & #define, etc are considered one of the most essential elements of C programming. However, there are no preprocessors in JAVA. JAVA uses other alternatives for the preprocessors. For instance, public static final is used instead of the #define preprocessor. Java maps class names to a directory and file structure instead of the #include used to include files in C.

9. The standard Input & Output Functions.
Although this difference might not hold any conceptual(intuitive) significance, it’s maybe just the tradition. C uses the printf & scanf functions as its standard input & output while JAVA uses the System.out.print & functions.

10. Exception Handling in JAVA And the errors & crashes in C.
When an error occurs in a Java program it results in an exception being thrown. It can then be handled using various exception handling techniques. While in C, if there’s an error, there IS an error.

4. Elaborate the difference between Java and C Plus Plus
Interpreted vs. compiled: Java is an interpreted language, which means it is “translated” to binary at the time of execution. This allows it to run on any operating system regardless of where it was written. C++ is a compiled language, which means your program is compiled on a specific operating system and runs only on that particular operating system. If you want it compatible with another operating system, you must compile your program on it.
Memory safe: Java is a memory-safe language, which means if you attempt to assign values outside of the given array parameters, the programmer receives an error. C++ is much more flexible, but this comes at a price. C++ will allow the programmer to assign values outside of the allocated memory resources, but this can later cause bugs and serious crashes during run-time.
Performance: Java is a favorite among developers, but because the code must first be interpreted during run-time, it’s also slower. C++ is compiled to binaries, so it runs immediately and therefore faster than Java programs.
Pointers: Pointers are a C++ construct that allows you to manage values directly in memory spaces. Java does not support pointers, so you are only able to pass values using value references.
Overloading: Overloading is a concept that “redefines” the functionality of a method or operator. Java allows method overloading while C++ allows you to overload operators.

5. Write a Program in Java to display " Hello World "

public class MyClass {
  public static void main(String[] args) {
    System.out.println("Hello World");
Every line of code that runs in Java must be inside a class. In our example, we named the class MyClass. A class should always start with an uppercase first letter.

Note: Java is case-sensitive: "MyClass" and "myclass" has different meaning.

The name of the java file must match the class name. When saving the file, save it using the class name and add ".java" to the end of the filename.
Inside the main() method, we can use the println() method to print a line of text to the screen. 

6. what is an application in Java ?
	It is a stand-alone Java program that runs with the support of a virtual machine in a client or server side. Also referred to as an application program, a Java application is designed to perform a specific function to run on any Java-compatible virtual machine regardless of the computer architecture. An application is either executed for the user or for some other application program. Examples of Java applications include database programs, development tools, word processors, text and image editing programs, spreadsheets, web browsers etc.

Java applications can run with or without graphical user interface (GUI). It’s a broad term used to define any kind of program in Java, but limited to the programs installed on your machine. Any application program can access any data or information or any resources available on the system without any security restrictions. Java application programs run by starting the Java interpreter from the command prompt and are compiled using the javac command and run using the java command. Every application program generally stays on the machine on which they are deployed. It has a single start point which has a main() method.

7. Write short notes on Java Applet .
	Unlike a Java application program, an applet is specifically designed to be executed within an HTML web document using an external API. They are basically small programs – more like the web version of an application – that require a Java plugin to run on client browser. They run on the client side and are generally used for internet computing. You can execute a Java applet in a HTML page exactly as you would include an image in a web page. When you see a HTML page with an applet in a Java-enabled web browser, the applet code gets transferred to the system and is finally run by the Java-enabled virtual machine on the browser.

Applets are also compiled using the javac command but can only run using the appletviewer command or with a browser. A Java applet is capable of performing all kinds of operations such as play sounds, display graphics, perform arithmetic operations, create animated graphics, etc. You can integrate an applet into a web page either locally or remotely. You can either create your own applets locally or develop them externally. When stored on a local system, it’s called a local applet. The ones which are stored on a remote location and are developed externally are called remote applets.

Browsers come with Java Runtime environment (JRE) to execute applets and these browsers are called Java-enabled browsers. The web page contains tags which specify the name of the applet and its URL (Uniform Resource Locator) – the unique location where the applet bytecodes reside on the World Wide Web. In simple terms, URLs refer to the files on some machine or network. Unlike applications, Java applets are executed in a more restricted environment with harsh security restrictions. They cannot access the resources on the system except the browser-specific services.

8. What is a class ? Support your answers with examples.
Classes and Objects are basic concepts of Object Oriented Programming which revolve around the real life entities.
A class is an entity that determines how an object will behave and what the object will contain. In other words, it is a blueprint or a set of instruction to build a specific type of object.A Class is like an object constructor, or a "blueprint" for creating objects.
A class is a user defined blueprint or prototype from which objects are created.  It represents the set of properties or methods that are common to all objects of one type. In general, class declarations can include these components, in order:

Modifiers : A class can be public or has default access (Refer this for details).
Class name: The name should begin with a initial letter (capitalized by convention).
Superclass(if any): The name of the class’s parent (superclass), if any, preceded by the keyword extends. A class can only extend (subclass) one parent.
Interfaces(if any): A comma-separated list of interfaces implemented by the class, if any, preceded by the keyword implements. A class can implement more than one interface.
Body: The class body surrounded by braces, { }.

9. What is an object in object oriented programming system?
	It is a basic unit of Object Oriented Programming and represents the real life entities.  A typical Java program creates many objects, which as you know, interact by invoking methods.
An object is nothing but a self-contained component which consists of methods and properties to make a particular type of data useful. Object determines the behavior of the class. When you send a message to an object, you are asking the object to invoke or execute one of its methods.

From a programming point of view, an object can be a data structure, a variable or a function. It has a memory location allocated. The object is designed as class hierarchies.


ClassName ReferenceVariable = new ClassName()
What is the Difference Between Object & Class?
A class is a blueprint or prototype that defines the variables and the methods (functions) common to all objects of a certain kind.

An object is a specimen of a class. Software objects are often used to model real-world objects you find in everyday life.

Download in Word

Our Proud Members

Courses For Free

Register Now

Noidatut is an E Learning Platform for students to get CLASS NOTES AND LAB MANUALS. This is simple E Learning Platform where we aim to have the largest collection of E - Books and other study resources. We have the notes for different curces starting from Engineering to Diploma.