0% found this document useful (0 votes)
6 views

java

Uploaded by

Pawan Agnihotri
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

java

Uploaded by

Pawan Agnihotri
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Java is a class based high level object oriented programming language developed by

“James Gosling” in 1991 produced by Sun Microsystems. It is portable and plateform


independent language.

Features of Java :

1. Object Oriented
2. Platform Independent
3. Simple language
4. Secure
5. Portable
6. Compiled & Interpreted
7. Robust
8. Distributed
9. Multi-Threaded
10. Performance
11. Dynamic
12.

Class hello
{
public static void main(String args[])
{
System.out.println(“Hello World”);
}
}

Que. What is a Bytecode in Java?


Ans. It acts similar to an assembler. As soon as a java program is compiled, java
bytecode is generated.
OR
When an application is written in Java, the Java compiler converts the source code to
bytecode, outputting the bytecode to a CLASS file. Byte code is the intermediate
code compiled and executed by a virtual machine (VM). Bytecode is the compiled
format for Java programs.
OR
As soon as a Java program is compiled bytecode is generated. To be more precise a
Java bytecode is the machine code in the form of a class file. A bytecode in Java is the
instruction set for Java Virtual Machine.
OR
Bytecode - A Java compiler instead of translating Java code to machine language
code, translates it into Java Bytecode. When the bytecode runs on a computer, a Java
interpreter translates the bytecode into machine code and then executes it.

Java program [Source code] Java compiler Java byte code

Que - Why is Java considered as Object Oriented Programming language? Explain


data members and member methods with the help of an example.

 Java Language is considered an Object-Oriented Programming Language because


it is based on the concept of objects and classes. Java supports the concepts of
OOPs- Inheritance, Data abstraction, polymorphism, and data encapsulation.
 In an OOPs language, a program is a collection of objects that interact with other
objects to solve a problem. Each object is an instance of a class.
 Without the creation of objects and classes, it is impossible to write any code in
Java.
Data Members : The data members of a class are like global variables - they can be
accessed by all the method members of the class.

Method members of a class are invoked on an object to perform the action


associated with that method.

Example:

class Bicycle
{
private int gear=5;
public void braking ()
{
System.out.println (“Working of Braking”);
}
}

Que - Java is a platform independent language'. Justify the statement.


Ans. Once a programmer has compiled a Java program into bytecode, it can be run
on any platform (like Windows, Linux, or Mac) as long as it has a JVM running on it.
This makes Java programs platform independent and highly portable.
OR
Java is a platform-independent language, means that we can run the same code on
multiple platforms without making any changes. Java achieves this using JVM and
Byte Code.
OR
The byte code generated by source code compilation would run in any operating
system, but the JVM present in a machine differs for each operating system.

Java Code

Java Compiler

Byte Code

JVM

Mac Windows Linus

You might also like