java basic interview questions


1.What is a class?
A class is simply a representation of a type of object. It is the blueprint/ plan/ template that describe the details of an object.

2.   What is an object?
Object is termed as an instance of a class, and it has its own state, behavior and identity.

3.What are members of Class?
When we create a class its totally incomplete without defining any member of this class same like we can understand one family is incomplete if they have no members.
Field: field is nothing but the property of the class or object which we are going to create .for example if we are creating a class called computer then they have property like model, mem_size, hd_size, os_type etc
Method: method is nothing but the operation that an object can perform it define the behavior of object how an object can interact with outside world .startMethod (), shutdownMethod ().
Access Level of members: Access level is nothing but where we can use that members of the class.
Each field and method has an access level:
private: accessible only in this class
package or default: accessible only in this package
protected: accessible only in this package and in all subclasses of this class
public: accessible everywhere this class is available


4.How java is platform independent?

Java is Considered as Platform independent because of many different reasons which are listed below -

Output of a Java compiler is Non Executable Code i.e Bytecode.Bytecode is a highly optimized set of instructions

Bytecode is executed by Java run-time system, which is called the Java Virtual Machine (JVM).

Important Note :

As the output of Java Compiler is Non Executable Code we can consider it as Secure (it cannot be used for automated execution of malicious programs).

JVM is an interpreter.

JVM accepts Bytecode as input and execute it.

Translating a Java program into bytecode makes it much easier to run a program in a wide variety of environments because only the JVM needs to be implemented for each platform.

For a given System we have Run-time package , once JVM is installed for particular system then any java program can run on it.

However Internal details of  JVM will differ from platform to platformbut still all understand the Same Java Bytecode.

Author

Written by Admin

Aliquam molestie ligula vitae nunc lobortis dictum varius tellus porttitor. Suspendisse vehicula diam a ligula malesuada a pellentesque turpis facilisis. Vestibulum a urna elit. Nulla bibendum dolor suscipit tortor euismod eu laoreet odio facilisis.

1 comment:

  1. The information which you have provided is very good. It is very useful who is looking for basic interview questions.

    ReplyDelete