Getting Started with Java

Getting Started with Java

1.What is meant by Object oriented programming?
A.OOP is a method of programming in which programs are organized as cooperative collections of objects.Each object is an instance of a class and each class belong to a hierarchy.

2.Is Java a purely object oriented language or not?
A.   i.purely object oriented means it should contain only classes and objects.It should not contain primitive data types like int,float,char,etc..Since they are neither classes nor objects.  
   ii.In pure object oriented language,we should access every thing by message passing . But,Java contains static variables and methods which can be accessed directly without  using         objects.
   iii.Java does not contain multiple inheritance.It means an important feature of object oriented design is lacking .so how can we say it is purely object oriented?
    
    No doubt java is a purely Object oriented programming language.The preseding points represent lack of indepth understanding in java.

     i.Even if java is primitive datatypes,these types are used inside a class and never outside of it.So,they are part of a class .See the API specification on the calss:'Class'.java          specification says that all the arrays and the primitive java types.

  ii.Any purely object oriented language should follow alll the 5 features of Object oriented programming System.They are 1.Classes and          objects.2.Encapsulation,3.Abstaraction,4.Inheritance and 5.polymorphism.Remember java contains all these features and hence it is purely object oriented language.

3.What do you mean by platform independence of Java?
A.Platform independence means that you can run the same Java Program in any Operating System. For example, you can write java program in Windows and run it in Mac OS.

4.What is JVM and is it platform independent?
A. Java Virtual Machine (JVM) is the heart of java programming language. JVM is responsible for converting byte code into machine readable code. JVM is not platform independent, thats why you have different JVM for different operating systems. We can customize JVM with Java Options, such as allocating minimum and maximum memory to JVM. It’s called virtual because it provides an interface that doesn’t depend on the underlying OS.

5.What is the difference between JDK and JVM?
A.Java Development Kit (JDK) is for development purpose and JVM is a part of it to execute the java programs.JDK provides all the tools, executables and binaries required to compile, debug and execute a Java Program. The execution part is handled by JVM to provide machine independence.

6.What is the difference between JVM and JRE?
A.Java Runtime Environment (JRE) is the implementation of JVM. JRE consists of JVM and java binaries and other classes to execute any program successfully. JRE doesn’t contain any development tools like java compiler, debugger etc. If you want to execute any java program, you should have JRE installed.

7.Why pointers are eliminated from Java?
 A.     i.pointers lead to confusion for a programmer.
        ii.pointers may crash a program easily,for example ,when we add two pointers,the program crashes immediately.The same thing could also happen when we forgot to free the                      memory  allotted to a variable and reallot it to some other variable.
        iii.pointers a break security,Using pointers,harmful programs like virus and other hacking programs can be developed.Because of the above reasons,pointers have been eliminated from java.

8.Why Java doesn’t support multiple inheritance?
A.Java doesn’t support multiple inheritance in classes because of “Diamond Problem”. To know more about diamond problem with example, read Multiple Inheritance in Java.
      However multiple inheritance is supported in interfaces. An interface can extend multiple interfaces because they just declare the methods and implementation will be present in the implementing class. So there is no issue of diamond problem with interfaces.

9.Which part of JVM will allocate the memory for a java program?
A.class loader subsystem of JVM will allocate the necessary memory needed by the java program.

10.Which algorithum used by garbage collector to remove the unused variables or objects from memory?

 A.Garbage collector uses many algorithms but the most commonly used algorithm is mark and sweep.

11.How can you call the garbage collector?

A.Garbage collector is automatically invoked when the program is being run.It can also called by calling gc()method of Runtime class or System class in java.

12.what is JIT compiler?


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

0 comments:

Post a Comment