shilpa gupta

Greenhorn
+ Follow
since Feb 09, 2001
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 shilpa gupta

hi
i am a sun certified java developer with 1.5 years experience.
my Skill sets are:
Internet Skills : JAVA(Applet, Servlet, JDBC, multithreading), JSP
JavaScript, HTML.
RDBMS: Oracle 8.0 , MS - Access 97.
GUI: Visual Basic 6.0
Programming Language : ' C ', SQL Plus, PL/SQL.
Operating System : Ms Windows 98, Windows NT.
Application Server: Java Web Server.
Application Tool: Jdeveloper 2.0.
Internet Designing : Microsoft Front Page 2000, Alliare HomeSite 4.0

if this interests anybody plase feel free to mail me at shilpa_gupta78@rediff.com
thanx
shilpa
22 years ago
Q. What will be the result of executing the following code
public class MyClass
{
public static void main (String args[])
{
String str = "SCJP";
String str2 = ""; // There is no space
// between double quotes
System.out.println(str == str + str2);
}
}
Will print false
--------------------------------------------------------------------------------
Q. What will be the result of executing the following code
public class MyClass
{
public static void main (String args[])
{
String str = "SCJP";
String str2 = str.concat(""); // There is no space
// between double quotes
System.out.println(str == str2);
}
}
Will print true

why ?
what is the diff between "+" and concat()?
2]
How many String objects are created when we run the following code.
String s1,s2,s3,s4;
s1 = "Hello";
s2 = s1;
s3 = s2 + "Pal";
s4 = s3;
ans is 3 but i don't agree.
what do all say?

[This message has been edited by shilpa gupta (edited March 05, 2001).]
that's the question guys?
what does intern() method do?
D1]
class ch_zero{
public static void main(String args[]){
if(0.0 >- 0.0){System.out.println("0.0 is greater");}
else
if(-0.0>0.0){System.out.println("-0.0 is greater");} //FIRST CHECK FOR 0.0
else
System.out.println("0.0 and -0.0 are equal");
System.out.println(0.0 ==-0.0);//SECOND CHECK FOR 0.0

if(0 >- 0){System.out.println("0 is greater");}
else
if(-0 >0){ System.out.println("-0is greater");} //FIRST CHECK FOR 0
else
System.out.println("-0 and 0 are equal");
System.out.println(0 ==-0);//SECOND CHECK FOR 0

System.out.println(Math.min(0.0,-0.0));
System.out.println(Math.max(0.0,-0.0));

System.out.println(Math.min(0,-0));
System.out.println(Math.max(0,-0));
}
}
in the above code both the cheks for 0.0 prove that 0.0 equals -0.0
then why does min() and max() methods give diff answers.
D2]
Assume that th is an instance holding a thread object. th.start() causes the thread to start running and eventually complete its execution. The object reference by th is not accessable any more and is garbage collected when the garbage collecter runs.

True
False
ans = false why?
D3]
The following code builds a GUI with a single button.
1. import java.awt.*;
2.
3. public class Q6 extends Frame {
4. setSize(500,500);
5. setLayout(new FlowLayout( ) );
6.
7.
8. Button b = new Button("Where am I ?");
9. Panel p1 = new Panel( );
10. p1.setLayout(new FlowLayout(FlowLayout.LEFT ));
11. Panel p2 = new Panel( );
12. p2.setLayout(new BorderLayout( ));
13. panel p3 = new Panel( );
14. p3.setLayout(new GridLayout( 3, 2 ) );
15.
16. p1.add(b);
17. p2.add(p1, BorderLayout.NORTH);
18. p3.add(p2);
19. add(p3);
20 }
21.
22. public static void main(String args[ ]) {
23. Q6 that = new Q6( );
24. that.setVisible(true);
25. }
26. }
i can't figure out the ans .can somebody help?
D4]
class ch_inner1{
ch_inner1(){
new inner().meth1(); // line 2
}
public static void main(String args[]){
//new ch_inner1().new inner().meth1(); // -----line 1
new ch_inner1();
}
class inner{
void meth1(){
System.out.println("inner");
}
}
}

in the ex D4]
if at line1 i try to instantiate inner class as follows and call the method meth1
new inner().meth1();
i get compile time error saying instane of outer class req.
from which i conclude that inner class can not be craeted without the instance of it's outer class.
but then again if i call method meth1() as in line two without instaniating outer class this time from the constructor of outer class i do not get any errors.
what's happening here.
pleas clarify my doubt.
thanx guys
tel me another thing can transient var. then be static or not.
writing static transient int i = 2;(as instance var)
gives no errors.
and in Q 2]
am i not creating a new String when i write
s4 = s3 +"";
hi all
can anybody please please tell me as to when these
two can be used.
is it right to write
for(int i = 0; i<3; i++){
continue;//or break;
System.out.println("hi all");
}
please ans this
[This message has been edited by shilpa gupta (edited March 02, 2001).]

experts
we need your guidance here.things are becoming more & more confusing
help us out please.
thanx
shilpa
1]
String s9 = "addme";
String s10 = "add";
String s11 = "me";
System.out.println(s9 == (s10+s11));
System.out.println(s9 == "add" + "me");
in the above ex.
i get a false & true. i don't get the diff between the two statements. please explain
2]
String s3 = "java";
String s4 = s3+"";
String s5 = new String("java");
String s6 = s5+"";
System.out.println(s3 == s4);
System.out.println(s3.equals(s4));
System.out.println(s5 == s6);
System.out.println(s5.equals(s6));
here i get all four ans as true
but in the code below ans is false .
String str = "SCJP";
String str2 = ""; // There is no space
// between double quotes
System.out.println(str == str + str2);
THIS IS VERY CONFUSING . HELP ME OUT OF THIS PLEASE.
3]as per the rule of unary implicit conversions short,byte,char values are incremented to int.
then why
char c = 'a';
c = ++c;
OR
byte b = 10;
b = ++b;
does not give any errors.
4] khalid mughal on pafe 126 says transient variables can not be static.
i tried the following code and it works fine.
class abc{
transient int i = 10;
}

but if i change it to
class abc{
public static void main(String args[]){
transient int a = 10;
}
}
it does not compile.
why?
3]
is it true that :
a) if sleep() method is called on any thread in a synchronized method it does NOT relaese the lock on the object
b)the access modifier of the default constructor is same as that of it's class.
i believed it was public always.
c) class fields with static modifier will not be serialised.
d) if a runtime exception is thrown in finalize method it is simply ignored and the object is garbage collected.
e) if an object is re_referenced in it's finalize method it is not garbage collected in that sweep but in the next sweep of G.C the finalize method will not be called and the object will be garbage collected.
2]
A)
import java.awt.*;
public class TestFrame extends Frame
{
Button bNorth = new Button("North");
Button bSouth = new Button("South");
Button bEast = new Button("East");
Button bWest = new Button("West");
Button bCenter = new Button("Center");
public TestFrame()
{
setLayout(new BorderLayout());
add(bSouth,BorderLayout.SOUTH);
add(bWest,BorderLayout.WEST);
add(bEast,BorderLayout.EAST);
add(bNorth,BorderLayout.NORTH);
add(bCenter);
setLayout(new FlowLayout());
validate();
pack();
setVisible(true);
}
public static void main(String args[])
{
TestFrame tf = new TestFrame();
}
}
B) import java.awt.*;
public class TestFrame extends Frame
{
Button bNorth = new Button("North");
Button bSouth = new Button("South");
Button bEast = new Button("East");
Button bWest = new Button("West");
Button bCenter = new Button("Center");
public TestFrame()
{
setLayout(new FlowLayout());
add(bNorth);
add(bSouth);
add(bWest);
add(bEast);
add(bCenter);
setLayout(new BorderLayout());
validate();
setSize(300,300);
setVisible(true);
}
public static void main(String args[])
{
TestFrame tf = new TestFrame();
}
}
first program gives buttons arrnged according to flowLayout
but the second one does not display any buttons.
Why?
1 ]
a call super() is made by constructor of every subclass implicitely but is this true for methods also.(i. e) if a call is made to the method of subclass does it check for that method in the super class also.
the following code results in compile time error saying"method getFields() not found in class Base"
please explain
class Base {

}
class Agg extends Base{
public String getFields(){
String name = "Agg";
return name;
}
}
public class Avf{
public static void main(String argv[]){
Base a = new Agg();
System.out.println(a.getFields());
}
}
2]why does this give me ans as 10,0 & 20
10,0 i can understand but if the valiue v.i has been made 10 then why does it give20 again.
please clarify.
class ValHold{
public int i = 10;
}
public class ObParm{
public static void main(String argv[]){
ObParm o = new ObParm();
o.amethod();
}
public void amethod(){
int i = 99;
ValHold v = new ValHold();
v.i=30;
another(v,i);
System.out.println(v.i);
}//End of amethod
public void another(ValHold v, int i){
i=0;
v.i = 20;
ValHold vh = new ValHold();
v = vh;
System.out.println(v.i+ " "+i);

}
//End of another
}
CONGRATS DAVID
that's a greatscore.
tell me in what depth did you prepare for awt(esp gridbaglayout) & I/O .
shilpa
23 years ago
doesit mean that evtime i assign a subclass to superclass and need to call a method from subclass that methd shold be present in superclass also.
can you please explain lte binding concept in little depth
thanx
shilpa
hi all
kindly let me know if there are any q on gblayout & I/O
andthey areof what kind .pleasespecify on both the topics.
thanx
shilpa
23 years ago
congrats Anupama
tell me werethere q on gridbagLayout where we need to analyse the results.
how much did you prepare in gridbaglayout.
and how were the q on I/O
shilpa
23 years ago