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

Java Theory - Java Basics

Java

Uploaded by

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

Java Theory - Java Basics

Java

Uploaded by

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

Java Basics

1. What is Java?
Ans.
Java is a simple and powerful high level, object oriented programming language. Java originated at Sun
Microsystems, Inc. in 1991. It was developed to provide a platform-independent programming language.

2. Who conceived Java?


Ans.
It was conceived by James Gosling and was initially called ‘Oak’

3. Why is Java called as platform Independent Language?


Ans
Java was designed with a concept of ‘write once and run everywhere’. Unlike many other programming
languages including C and C++ when Java is compiled, it is not compiled into platform specific machine
code, rather it is converted into platform independent byte code. This byte code is distributed over the
web and interpreted by virtual Machine (JVM) on whichever platform it is being run.

4. What is the difference between compiler and interpreter?


Ans.
Compiler Interpreter
The program that translate the source The program that translate the source
program or source code to machine language program or source code to machine language
or low-level language at once is known as or low-level language step by step or line by
compiler. line is known as interpreter.

1
Faster execution of control statements as Slower execution of control statements as
compared to the interpreter. compared to the compiler.
Detected errors in the program get displayed Detected errors in the program get displayed
after the entire program is read by compiler. after each instruction read by the interpreter.
Example: C++, Java. Example. Python, PHP.

5. What are advantages of object oriented programming? / Why is Java called as Object
Oriented Language?
Ans. Unlike procedural languages, in Java we can create objects, which offer many
advantages:
 Objects are created on real world entities.
 Complex systems of real world can be converted into software solutions.
 Objects can be easily reused in other programs due to its re-usability feature.
 Objected oriented programs focuses the developer to do extensive planning which will
reduces programming flaws and better design.
 Software maintenance of the object oriented program is easier than as compared with
structured oriented programming.

6. What is the difference between source code and object code?


Ans.
source code object code
The set of instructions and statements written The machine language program produced
by computer programmer using a after the compilation of the source code is
programming language to find solution of known as object code or object module or
problem is known as source code or program object program.
Human Readable Machine Readable
Created by the programmer Created by the Compiler

7. What is Byte Code?


Ans. Byte code is also called as intermediate code. Java byte code is byte long instruction set
that Java compiler generates and stores in .class files. Java compiler converts Java
source code into platform independent bytecode. It needs JVM to execute byte code to
run.

2
8. What is JVM?
Ans. The java run-time system which translates or interprets byte code into machine code is
known as Java Virtual Machine (JVM) or java Interpreter.
A JVM can either interpret the bytecode one instruction at a time or the bytecode can
be compiled further for the real microprocessor using what is called a just-in-time
compiler.
The JVM must be implemented on a particular platform before compiled programs can
run on that platform.

3
9. What is JDK?
Ans.
JDK is a kit(or package) which includes two things i) Development Tools(to provide an
environment to develop your java programs) and ii) JRE (to execute your java program).

10. What is full form of IDE? Give example of 2 IDE.


Ans.
IDE stands for Integrated Development Environment. IDE for developing Java Application is
Eclipse, NetBeans, JDeveloper, MyEclipse, BlueJ.

11. What is BlueJ?


Ans.

4
BlueJ is an integrated development environment (IDE) for the Java programming language, developed
mainly for educational purposes, but also suitable for small-scale software development.
 It has a built in editor
 Interactive interface to create and test objects
 Ability to run applications

12. What is the difference between Applets and application?


Ans.
Applets Applications
It is a portable language and can be Its program coding is large as compared
executed by any JAVA supported to applets.
browser.
It executed or runs a program on client It can be executed on standalone
browser. computers.
The applets are created by using The applications are created by using
java.applet.Applet package. method:
"public static void main(String args[ ])"

1. What are comments? What are different types of comments found in the program?
Ans. • Comments are descriptions that are added to the program to make code easier to
understand.
• Compiler ignores the comments
Type Syntax Usage
Single-line // comment All characters after the // up to the end of the line
are ignored.
Multiline /* comment */ All characters between /* and */ are ignored.
Documenting /** Comment The JDK javadoc tool uses doc comments when
(Doc) */ preparing automatically generated documentation.
Comment

13. What are different types of errors you find in your program?
Ans. Syntax errors:
 Errors occurring when you violate a syntax rule.
 Caught during compile time
 E.g. forgetting to terminate program statement with ;
Logical errors:
 Also called design errors or bugs which escape compilation
 Occurs when logic of the program is incorrect.
 Can be fixed by testing & debugging the program
 E.g. PI = 31.4;

5
Run-time errors:
 Occur when we ask the computer to do something it considers to be illegal.
 In these cases Java throws exception
 E.g. dividing by zero

14. What are Escape Sequences?


Ans.
Escapes Sequences represents special control characters and characters that cannot be printed.
• They are special type of character literal
• Represented by a Backslash (\) followed by a character code

Escape Sequence Description

\t Insert a tab in the text at this point.


\b Insert a backspace in the text at this point.
\n Insert a newline in the text at this point.
\r Insert a carriage return in the text at this point.
\f Insert a formfeed in the text at this point.
\' Insert a single quote character in the text at this point.
\" Insert a double quote character in the text at this point.
\\ Insert a backslash character in the text at this point.

You might also like