Header Ads Widget

JAVA assignment-1 Introduction to JAVA

_Introduction to Java 

3350703

Assignment-1

1: Explain Following terms:(i)Platform Independent (ii) Byte Code (iii) Applet (v) JVM (iv) JRE

Answer:-

 -Platform Independent:
Platform Independent refers to independent of any OS, java compiler generates a platform independent code.

-Byte Code 
Java compiler generates a platform independent code called Byte Code.

-Applet 
Applets are used to provide interactive features to web applications and can be executed by browsers for multiple platforms.

-JVM 
Java Virtual Machine is a program that runs pre compiled Java programs, which mean JVM executes .class files and produces output.

-JRE
JRE executes Java Programs. JRE is required to execute pre-compiled Java Programs.

b

2. Explain different features of Java.

Answer:-

Simple:-

Java is a simple language and is Easy to write and read.

Object Oriented:-

Java is a pure object oriented programming every entity in java is object.

Distributed:-

Java has networking facilities, so, it allows the Object to access information across the network between multiple machines.

Platform Independent:-

Platform independent refers to independent refers of any OS, java compiler generates a platform independent code.

Architecture neutral:-

Architecture neutral refers to hardware independent or format of this system independent binary code.

Multithreaded:-

It means that handling more than one job at a time, threads are light weight process. 

Dynamic:-

Java is a dynamic language, it is capable of linking dynamic new classes, methods and objects during runtime.

Portable:-

The Byte code generated by java compiler can be used on any machine, so java is portable.

High Performance:-

The use of Byte code makes the performance high.

Robust:-

Robust means strong, where it checks the reliability of the code before execution.

Secure:- 

Java does not use memory pointers explicitly.
Java use the encryption systems for applications to secure them on internet. 

Interpreted:-

Generally, computer languages are either compiled or interpreted. But Java combines both compiler and Interpreted.

3. Explain different OOP concepts.

Answer:-

-Encapsulation:-

It is a process of wrapping of data and methods in a single unit.

it is achieved in Java language by class concept.

The main advantage of using encapsulation is to secure the data from other methods.

-Inheritance:-

The process by which one object can use properties of another object is called inheritance.

Inheritance has feature in which we can reuse the code and hence it avoids to writing the same code again and again.

-Polymorphism:-

Polymorphism is the ability of an object to change its behavior according to how it is being used.

There are two types of Polymorphism 1) Compile time Polymorphism 2) Runtime Polymorphism.

-Abstraction:- 

Abstraction separates specification from implementation of class.

It refers to act of representing essential features without including the background details.



4. Explain basic structure of Java programs.

Answer:-

The Java Programs involves :-

Document section:-this section is used to write a comments. Comments are useful to programmers because they help them understand the code.

Package statement:-You can create a package with any name. A package is a group of classes that are defined by a name.
 example:-    package package_name;

Import Statement:-You can use a class of another package by importing it directly into your program.
example:-   import calc.add;

Interface Statement:-Interfaces are like a class that includes a group of method declarations.

Class definition:-Classes are the main and essential elements of any Java program.

main method class:- Every Java program requires the main method as the starting point of the program. There may be many classes in a Java program, and only one class defines the main method.


5. Describe JVM (Java Virtual Machine).

Answer:-

JVM is a platform-independent execution environment that converts Java byte code into machine language and executes it.

The JVM is called "virtual Machine" because it provides a machine interface that does not depend on the underlying operating system and hardware architecture.

This independence supports the write-once run-anywhere concept of java programs.

Java Virtual Machine is a program that runs pre compiled Java programs, which mean JVM executes .class files and produces output. 

JVM handles following main tasks..
Code Loading, Byte Code Verification, Execution, Provided runtime environment.

6. Describe main() method in Java.

Answer:-

The main() is the starting point for JVM to start execution of java program.
syntax of java program is :--  
                   public static main(String args[])
where Public is access specifier.
 static is a keyword.
void is a return type.
 main() is the method name.
String args[] is a array of string type which accepts group of strings, which is called string array.

->>if we write main() method without String args[] then the program will compile but not run. 

7. Explain why JAVA is known as platform independent language?

Answer:-

Java is platform independent because it does not depend on any type of platform. 
Java programs are compiles into byte code and the byte code is platform-independent.
This Byte code can be interpreted on any system which has java Virtual Machine installed. This is why java is Portable Language.

8. Write differences between Java and C++. 

Answer:-

Java:-

Java does not support pointer unions and operator overloading and structure.

It support garbage collection.

It supports inheritance except multiple inheritance.

Java is interpreted.

Java does not supports Destructor.

C++:-

C++ supports pointer, unions, operator overloading and structure.

It does not supports garbage collection.

It supports inheritance including multiple inheritance.

C++ is compiled.

C++ supports Destructor.



Post a Comment

0 Comments