You are on page 1of 3

1.a)Is java purely objected oriented programinning?Explain ?

Ans:Java is not fully object oriented because it supports primitive data type like it,byte,long
etc.which are not objects.All operations performed on objects must be onlt through methods
exposed at the objects.Java language is not a pure objected oriented language as it contain
these properties:primitive Data type ex.

b)What is java virtual Machine and how it is considered in context of java’s platform independent
feature?

Ans:Java virtual machine is a apecification that provides runtime environment in which java
bytecode can be executed.the JVM acts as a”virtual” machine or processor.

The JVM is not platform independent. Java virtual machine provides the environment to
execute the java file.so, at the end it’s depends on your kernel and kernel is differ from OS to
OS.The JVM is used to both translate the bytecode into the machine language for a particular
computer and actually execute the corresponding machine language instructions as
well.without the JVM,you can’t run a java application.

3.a)What are the abstract classes and interfaces?How java performs the task of multiple inheritances
using interface?Explain with proper coding example?

Ans:An abstract class is a class that is declared abstract.It may or may not include abstract
methods.Abstracted classes cannot be instantiated,but they can be subclassed.When an
abstract class is subclass,the subclass usually provides implementations for all of the abstract
methods in its parent class.

An interface in the java programming language is an abstract type that is used to specify a
behavior that classes must implement.They are similar to protocols.

An interface contains variables and methods like a class but the methods in an interface are
abstract by default unlike a class.multiple inheritance by interface occurs if a class implements
multiple interfaces or also if an interfaces or also if an interface itself extends multiple interface.

Coding Example:

Interface AnimalEat{

Void eat ();

}
Interface AnimalTravel{

Void travel();

Class Animal implements AnimalEat,AnimalTravel {

Public void eat() {

System.out.println(“Animal is eating”);

Public void travel() {

System.out.print(“Animal is travelling”);

Public void travel() {

System.out.println(“animal is travelling”);

Public class Demo{

Public static void main(String args[]){

Animal a=new Animal();

a.eat();

a.travel();

b)Ans:
5.a)Why String objects are immutable in java? How can you create a mutable string?

Ans:The string is Immutable in java because string objects are cached in string pool.

Mutable means changing over time.strings are immutable in java,it means you can modify the
string.If you want to creat mutable string you can creat it by use of StringBuffer and String
builder.

b)Ans:Error.Null pointer exception.

c)Ans:kava

7.a)How can you assign the value of a blank final variable and a static blank final variable ?

Explain with Example?

Ans:A blank final is a final variable whos elaration acks an initialize.outhen must assign that
blank final variable in a constructor.The final property of class must have a value assigned
before object is created.so thelast point where you can assign value to them is constructor.

Static blank final variable:In the same way if you declarea static variable final without
initialization it,it is considered as static final variable.

b)Ans:i.654321.

ii.2

You might also like