vijay


{ City } bangalore
< Country > india
* Profession * se
User No # 3151
Total Questions Posted # 0
Total Answers Posted # 36

Total Answers Posted for My Questions # 0
Total Views for My Questions # 0

Users Marked my Answers as Correct # 461
Users Marked my Answers as Wrong # 82
Answers / { vijay }

Question { Cognizant, 27492 }

Explain difference between final, finally and finalize?


Answer

final:
final keyword can be applied to vairables,method,class.
fianl variable - You can't reassign/modify values to the
vaiables.
final class- You cannt extends(inherit) the class.
final method- You cannt override the final methods.

finally:

finally is used in try-catch (i.e exception handling in
java).
Each try contain only one finally blocks not more than
one.
There is no statement between catch block and try block.
It will be execute if exception is occure or not.
Mostly used for memeory release.

finalize:
This is method used to release the occupied memeory.
finally method must be protected or public otherwise
compile time error.

Is This Answer Correct ?    74 Yes 5 No

Question { 5466 }

What is the use of ?this??


Answer

this:
a. It call the overloaded(same class only)constructor
b.refer the current object.
c.U cant use 'this' in static method.

Is This Answer Correct ?    0 Yes 1 No


Question { 5862 }

What is the return type of read()?


Answer

the return type of read() is int. It return -1 then it
reach the end of line.

Is This Answer Correct ?    6 Yes 0 No

Question { 5106 }

In what circumstances, compiler will supply a default
constructor for a class?


Answer

If there is no constructor in the class , then the compiler
create a default constructor with access specifier of class.


class A{ } - compiler create default constructor for this
class.

Is This Answer Correct ?    0 Yes 0 No

Question { 4139 }

Which characters are allowed to use as the second character
of an identifier, and which characters are not allowed?


Answer

The Second letter may be
Alphabetic letters - a to z ot A to Z
Numerals - 0 to 9
Only special character $,_ and Euro currency symbols

Is This Answer Correct ?    2 Yes 0 No

Question { Technological University of the Philippines, 9789 }

How many ways can an argument be passed to a subroutine?


Answer

In java the arguments are passed by pass by value . Using
this pass by value way u can pass both primitive and object
type values.

Is This Answer Correct ?    6 Yes 1 No

Question { Satyam, 4698 }

what is mean by String and StringBuffer?
What is mean by Methooverriding and Overloading?


Answer

String:
1. Is final class.
2. Is immutable class i.e value can't change once it is
assigned.
3. When your text is not going to change ,then you use the
String.
4. is not thread safe


StringBuffer:

1. is final class.
2. is mutable object.
3. When your text is going to change and will be accessed
from multiple threads , then you use StringBuffer
4. is thread safe .

Method Overloading:
1. Morethan one method has same name and either the number
of argument or data type of arguments are differ.
2. Method can be overloaded in same class or its subclass.
3. Return type ,access specifier and throws Exception are
not part of overloading.
4. static method can be overloaded by nonstatic method.

Method Overriding:
1. A method has same name,return type, number of argument
and arguments data types are same in subclass and super class.
2. The subclass (inheriting) method has equal or higher
access specifier than it superclass method.
3. The subclass (inheriting) method's throws exception is
equal or subclass excpetion of superclass method(Inherited
class method).

Is This Answer Correct ?    7 Yes 0 No

Question { Satyam, 10517 }

what is mean by method signature?


Answer

Method signature means name of the method ,type of argument
and order of arguments.

The "return type" of method and "access specifier" are not
part of method signature.

Is This Answer Correct ?    3 Yes 0 No

Question { Infosys, 30498 }

what is overloading in java?


Answer

Method overloading:
More than one method have same name but different type
of argument or differnt no. of arguments available in same
class or it subclass is called overloading.

Return type of method and access specifier of method is
not a problem in method overloading.

class A{
void diaplay(int a,int b){ }
void display(float a,float b){ }
void display(float a, int b){ }
void display(int a,int b){
void display(){ }

}

Is This Answer Correct ?    46 Yes 22 No

Question { Elementus Technologies, 16740 }

What is run time polymorphism?


Answer

Method overrrideing is the runtime polymorphism.The
class's "object" only determine which method to called .
eg:
class SuperClassTest
{
public void display(){
System.out.println("Super class");
}
}
class SubClassTest extends SuperClassTest
{
public void display(){
System.out.println("Sub class");
}
}
public class TestPro {



public static void main(String[] args) {

SuperClassTest sub=new SubClassTest();
System.out.print("I am Calling
subclasstest's display() method: ");
sub.display();

SuperClassTest sup=new SuperClassTest();
System.out.print("I am Calling
superclasstest's display() method: ");
sup.display();
}

}


o/p:

I am Calling subclasstest's display() method: Sub class
Note: object is type of SubClassTest
I am Calling superclasstest's display() method: Super class
Note: object is type of SuperClassTest

Note:
Method overloading is compile time polymorphism.The
class "reference" type determine which method to be called.

Is This Answer Correct ?    13 Yes 0 No

Question { BMC, 5429 }

What is casting?


Answer

Casting means converting values from one data type to
other data type.For example to convert the int values to
float type vlaues.

Types of casting:
1. Downcasting -source is larger than destination type
2. upcasting - Source is smaller than destination type.

casting can be applicable to both primitive type and Object
type.

primitive type - convert numeral to floating point and vice
versa.
Object type - converting from subclass to super class or
vice versa.
superClassObj = subClassObj;

Is This Answer Correct ?    4 Yes 0 No

Question { 5482 }

long d =10;int i =0;i=d; /// is this possible? If d is very
long number (10 digits or some thing) then?


Answer

It display compile time error. Cant convert form long to
int. becacuse it -2 32 bit and long is 64bit, so u need to
type case the long value into int value.

Is This Answer Correct ?    1 Yes 2 No

Question { HP, 51886 }

What is difference between Iterator and for loop


Answer

In iterator the remove() is available to remove the
content/item but in for loop remove() not available.

Is This Answer Correct ?    52 Yes 10 No

Question { Corent Technology, 5441 }

What are batch updates. in jdbc


Answer

Batch Update provide the functionality of executing a group
of sql statement at single timing.

Steps:

1.set autocommit as false for connection .
connectionObject.setAutoCommit(false);
2.create sql statement and add to statement object.
statementObj.addBatch("sql1");
statementObj.addBatch("sql2");
statementObj.addBatch("sql3");
3.execute the batch of statement using executeBatch().
statementObj.executebatch();
4. commit the connection.
connectionObj.commit();

Is This Answer Correct ?    3 Yes 0 No

Question { 5471 }

what is run time polymorphism


Answer

In Java Method overriding is the runtime or late binding
polymorphism.

class object is determine which class method is invoked.

ex:

class A {
protected void display(){ }

}

class B extends A {

protected void display(){ }

}

class MainClass {
public static void main(String arg[]){

A objA=null;
objA=new B();
objA.display(); // it invoke the Class B's display()

objA=new A();
objA.display(); // it invoke the Class A's display()

}

}

Note: the class's object only determine which method to call.

Is This Answer Correct ?    2 Yes 0 No

Prev    1    [2]   3    Next