FAQ ON JAVA

WHY JAVA SUITABLE FOR INTERNET

Due to two reasons they are 1. It is system independent and hence its programs can run on any type of computer available on internet 2. It has security to save data , it eliminates a lot of security problems for data on internet.

WHY POINTERS ARE ELIMINATED FROM JAVA

1.      Pointer s lead to confusion to the programmer

2.      Pointers break the security. Using pointers harmful programs like virus and other hacking programs are developed

 

WHAT IS THE DIFFERENCE BETWEEEN FUCTION AND METHOD

 

Both are same but in java functions are called as methods, and in java every method should be written inside a class only. But in c++ functions can be write inside or outside the class.

 

WHICH ALGORITHM IS USED BY GARBAGE COLLECTOR

 

Mark and sweep algorithm

 

HOW CAN WE CALL GARBADE COLLECTOR

 

Calling gc() method of Runtime class or System class in java

 

WHAT IS JIT COMPLIER

 

JIT compiler is a part of JVM which increases the speed of a java program

 

WHAT IS AN API DOCUMENT

 

An api document is a .html file which contains description of all features of a software, product or technology

 

WHAT IS THE DIFFERENCE BETWEEN #include and import STATEMENTS

 

#include makes the compiler to go to standard library and copy the ode from the header file into the program. As a result the program size will increase.

Import statement makes the JVM to go to standard library and execute the code of header file their itself and substitute the result. Thereby the program size doesn’t change.

 

 

WHAT HAPPENS IF String args[] is not written in main()

 

The program will be compiled but JVM cannot run the program. To run any java program JVM should identify main() and start execute from main(). If we don’t write String args[] then JVM cant identify main() hence program cant be executed.

 

WHAT IS THE DIFFERENCE BETWEEN print() and println()

 

If we use print the JVM will print the message

If we use println() the JVM will print the message and cursor will come to next line.

 

WHAT IS THE DIFFERENCE BETWEEN FLOAT AND DOUBLE

 

Float can represent upto 7 decimals 1.1234567

Double can represent upto 15 decimals 1.123456789123456

 

WHAT IS UNICODE SYSTEM

 

Unicode is encoding standard which provides an unique number for every character no matter which language it is.

 

HOW POSITIVE AND NEGATIVE NUMBERS ARE REPRESENTED IN SYSTEM

 

+ve by 1’s compliment, _ve by 2’s compliment

 

OUT OF DO WHILE AND WHILE WHICH IS EFFICIENT

 

While loop is efficient because. Consider do while it doesn’t checks condition for first time. But while will check the condition from starting onwards. So while is efficient than do while loop

 

WHY GOTO STATEMENT IS NOT PRESENT IN JAVA

 

Goto statement leads to confusion for the programmer. Especially in large programs

 

WHAT IS DIFFERENCE BETWEEN return, System.exit(0), System.exit(1)

 

RETURN used to come out of method

System.exit(0) used to come out of program i.e., normal termination

System.exit(1) used to come out of program i.e.. When some error occurs

 

WHAT IS THE DIFFERENCE BETWEEN System.out and System.err

 

System.out used to display noramal messages on monitor

System.err used to display error messages on monitor

 

ON WHICH MEMORY ARRAYS WERE CREATED IN JAVA

 

Not only arrays every thing is created dynamically in java, so no wastage of memory in java

 

CAN YOU CALL main() METHOD FROM ANOTHER CLASS

 

Yes we can call main() of one class in another class by using its calss name Classname.main()

 

IS STRING IS A CLASS OR DATATYPE IN JAVA

 

String is a class present in java.lang package

 

CAN WE CALL CLASS AS DATATYPE

 

Yes we can call a class as datatype because it is defined by user so it can be called as user defined data type

 

WHAT IS OBJECT REFERENCE

 

Object reference is an hexadecimal value representing the memory address of object

 

WHAT IS THE DIFFERENCE BETWEEN == AND equals() WHILE COMPARING STRINGS

 

== operator compares the references of the string object but it doesn’t compare the content in them. But equals() will compare contents too.

 

WHAT IS A STRING CONSTANT POOL

 

String constant pool is another memory block where jvm stores all the string objects.

String s1=”hello”. Now s1 is stored in string constant pool

 

WHAT IS THE DIFFERENCE BETWEEN STRING AND STRINGBUFFER CLASS

 

String class objects are immutable i.e. their contents can’t be changed or modified

StringBuffer class objects are mutable i.e., their contents can be modified

 

WHAT IS THE DIFFERENCE BETWEEN Stringbuffer and StringBuilder CLASSES

StringBuffer class in synchronized and StringBuilder is not

 

WHAT IS OBJECT ORIENTED APPROACH

 

To design computer programs using classes and objects is known as object oriented approach

 

WHAT IS CLASS AND OBJECT

 

A class is a user defined or a class is collection of data members and member functions or a calss is blueprint

An object is real time entity

 

Class—blue print of building

Object—real building after construction

 

WHAT IS THE DIFFERENCE BETWEEN OOP AND OBJECT BASED

 

Both are same but inheritance is present in OOPS but it is not present in object based programming

 

OOPS- JAVA, SMALLTALK,C++

Object based: JavaScript, VB Script, and Action Script

 

WHAT IS HASH CODE

 

Hash code is a unique number allocate to objects by JVM

 

MyClass mc=new MyClass();

mc.hashCode()

 

CAN WE DECLARE A CLASS AS PRIVATE

 

No we cant declare a calss as private. If we declare a class as private then JVM during execution cant have permission to execute/ access the class

 

WHEN IS CONSTRUCTOR CALLED BEFORE OR AFTER CREATING OBJECT

 

Constructor is called concurrently when object is created

 

WHAT IS CONSTRUCTOR OVERLOADING

 

Writing two or more constructors with the same name but different paramenters is called as constructor overloading.

 

REMAINING WITH IN COUPLE OF DAYS STAY TUNED


No comments: