Alpana Singh

Ranch Hand
+ Follow
since Sep 27, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Alpana Singh

How to login Certmanager.I don't know about it.I tried to login as First time user but when I entered my id and registration number,it gave an error that this id is not in the database.I passed my exam on 11/14/05.Please help me and tell me what I have to do.

Thanks,
Alpana
17 years ago
Hi guys,

Passed SCJP 1.4 today with 95%.

I want to thank you all for this.One thing I want to share is that exam is really easy ,but we need to study hard and stick to the topics of certification.

Thanks again,

Alpana
17 years ago
Variables are set at complile time.Variables are accessed with the declared time ,which in this case is Helse.
"The result of an expression involving anything int-sized or smaller is always int".

eg.
byte b=3;
byte c=4;
byte d= b+c; //Error
byte d1=byte(b+c);//compiles fine.

Same is the case with short.

now if you code like

short s1= 10 + 11;//compiles fine

as 10 & 11 are compile time constant.

but

short s1=10;
shot s2= s1 + short(11); //here s1 is not compile time constant.it's value can change at runtime.
In your first program s1 is compile time constant and therefore s2=s1+11 doesn't give an error.

While in the second one s1 is not compile time constant and hence when u add s1+11 it will result in an int which is not implicitly casted to short.
When a class is loaded, static variables are initialized and static blocks are executed. If an object is created, then instance variables are initialized and non-static initializer blocks are executed, followed by the constructor body.

Why does this code give an error

public class T1{
int y;
T1(){
this(y);
}

T1(int k){
System.out.println(k);
}
public void amethod(){
y=2;
}

public static void main(String args[])
{
T1 tt=new T1();
}
}


Since the instance variable are initialised before constructor runs,it should have value of y=0.
public class Inst{
protected int myst;
public void go(int myst){
System.out.println(myst); //1
myst=myst; //2
}
public static void main(String args[])
{
Inst a=new Inst();
a.go(5);
System.out.println(a.myst);
}
}

Why the o/p s 5 0.
So it's like ,if an exception is not thrown in the try block and we try to catch that then it will give compiler error.

Am i right?
But a in int,How can we assign a boolean value to int.
public class Q56
{
static boolean x;
public static void main(String args[])
{
int a;
if(x)
a = x ? 1: 2;
else
a = x ? 3: 4;
System.out.println(a);
}
}

This code give o/p 4.

How can this be possible.
class Except extends Exception{}
public class Q48
{
public static void main(String[]args)
{
try
{
System.out.println(10/0);
}
catch(Except e)
{
System.out.println("catch block");
}
}
}


Why does this code gives a compiler error,"Except is nit thrown in try block".the statement 10/0 gives an arithmetic exception.Right?

Please help.
Now I got it.I was confused ny i++.

Thanks for detailed explanation.
public class Q7
{
public static void main(String[] args)
{

int i=3;
System.out.println(ii*=2 + i++);
}
}

I came across this question.When I ran this o/p is 15.How can o/p is 15.

Please tell me the logic.
yeah, i got it.variable b in method g() is shadowing the class variable and it's local to g().Am i right?
This is the question fron Khalid Mughals mock exam.

public class Qcb90 {
int a;
int b;
public void f() {
a = 0;
b = 0;
int[] c = { 0 };
g(b, c);
System.out.println(a + " " + b + " " + c[0] + " ");
}
public void g(int b, int[] c) {
a = 1;
b = 1;
c[0] = 1;
}
public static void main(String[] args) {
Qcb90 obj = new Qcb90();
obj.f();
}
}


I answered 001 as o/p

But the o/p is 101

How can this be possible.