Hello
Please help me out in finding the solutions of the following questions.
Q1).)Go throw the following code.
int i=0;
do{
System.out.pintln("value of i is"+ i);
}
while (i--<0);
System.out.pintln("the end");
}
Here i-- will be -1,and -1 is less than 0 means while is true so do loop shouls continue printing.
But the output is : value of i is 0
the end.
Please explain why???
Q2)
String s=null.
Which of the following codes will throw NullPointerException. and WHY
a)s!=null && s.length()=0;
b)s!=null & s.length()=0;
c)s!=null ll s.length()=0;
d)s!=null l s.length()=0;
Q3)what values of x of the follwoing code display "Test 2" and WHY???
Can u explain the logic also???
if(x4)
SOPLn("Test 1");
else if(x9)
SOPLn("Test 2);
else
SOPLn("Test 3");
a) x is valued between 0-4.
b) x is valued between 4-9.
c) x is valued more than 10
d) None
Q4)for fully ecapsulation of a class, which are true?
a)make all variables private
b) make all methods private.
c)make variables nd methods private.
d) make methods as protected,default, privat and variables as private.
Q5)what keyword is allowd for member variables to be initialed only once???
(is it final,)
Q6)what keywod would be used to get object lock of this?
Q7)int i=new int[10];
what is the value of i[5]
Q8)Can we stop a
thread indefinately if we wish to(True/False)
If True ,how.
Q9)An application consists of a set of user interfaces & the various operations are to be performed based on the various user invoked events. Which of the following are true for the above
application
(i) Extending Adapter classes is not suitable
(ii) Some listener interface must be implemented
(iii) If a particular event listener is implemented only the methods of interest to us need to be implemented
(iv) Multiple event listeners can be added to a single component
(v) The order in which the events are processed is the order in which the listeners are added
Q10)
class A
{
String str;
int x;
int z;
public A(String s , int a)
{
str = s ;
x = a ;
}
public A(int a,String s)
{
//
}
}
class B extends A
{
public B(String s, int a)
{
super(s,a);
}
public B(String s, int a, int c)
{
//P
z = c;
}
}
What code can be inserted at //P so that it fully implements the existing code to initialise the values of x & str.
Saurabh