Mamta Jha

Greenhorn
+ Follow
since Oct 18, 2000
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Mamta Jha

hi everybody,
My doubt is
1.String s=null;
System.out.println(s.length());
should throw nullpointer exception,but it shows 0.why?
2.for(int i=0; i<N; i++)>
String tmp = "test"; //why this shows compilation error as variable redeclaration
I'll be thankful,if anybody could answer these ques
Thanks,
Mamta
I have a doubt regarding marking in real exam.If a ques has more than 1 correct answer and I miss one of the answers or 1 of the ans is wrong ,do I get 0 for that ques.
Plz clear my doubt.
Thanks,
Mamta
hello everybody,
These are the few ques from various mock exams in which I've got doubts .I'll be thankful if anyone can help me with these ques
Q1.Which of the following would be a valid inner class for this class?
Select all valid answers.
a) class B {
}
b) class B extends A {
}
c) class B {
B() {
System.out.println("i = " + i);
}
}
d) class B {
class A {
}
}
e) class A {
}
ans given is a&c.But I think b is also correct.
Q2.
Which statement is true about a non-static inner class?
A.It must implement an interface.
B.It is accessible from any other class. //why is this option wrong?
C.It can only be instantiated in the enclosing//ans
class.
D.It must be final if it is declared in a method
scope.
E.It can access private instance variables in the
enclosing object. //ans
Q3.
for(int i=0; i<N; i++)>
String tmp = "test"; //why this loop shows compilation error as variable redeclaration

Q4.Why '\u000A' is invalid expr while '\uBABE' is valid?
Q5.
. Which of the following places no constraints on the type of elements, order of elements, or repetition of elements with in the collection.?
A) Collection
B) collection//ans given
C) Map
D) Set
Do we have anything as collection?
Q6.
import java.io.*;
public class TestIPApp {
public static void main(String args[]) {
RandomAccessFile file = new RandomAccessFile("test.txt", "rw");
file.writeBoolean(true);
file.writeInt(123456);
file.writeInt(7890);
file.writeLong(1000000);
file.writeInt(777);
file.writeFloat(.0001f);
file.seek(5);
System.out.println(file.readInt());
file.close();
}
}
Select correct answer:
A) 123456
B) 7890 //ans
C) 1000000
D) .0001
Can anyone explain why is this option correct?
Thanks in advance,
Mamta
hi everyone,
1> In the foll. ques
To create a file,you can use an instance of class
a>File
b>randomaccessfile
c>FileOutputStream
d>any of these //ans
e>b and c
but acc. to me it should be a>File as we use an instance of File class to create a file like,
File f=new File("file name");
FileOutputStream fos=new FileOutputStream(f);
RandomAccessFile ras=new RandomAccessFile(f);
2> Can an applet be added to a container?
I think it can't be as it itself is a container
pl.anybody clear my doubt
thanks in advance,
Mamta
thanks jane & suneeta
mamta
hi friends,
These are some of the quest from a mock exam-
Q1. Which of the following are true about the class defined inside an interface
1> it is not possible in the java Laungage. //ans
2> The class is always public.
3> The class is always static.
4> the class methods cannot call the methods declared in the interface.
5> the class methods can call only the static methods declared in the interface.
my ans is 2.
Q2.What does the following expression return
Math.max(Float.POSITIVE_INFINITY,Double.POSITIVE_INFINITY);
1>Float.POSITIVE_INFINITY
2>Double.POSITIVE_INFINITY //ans
3>runtime Exception
when I tried this using a code , the answer comes id infinity.Does Double.POSITIVE_INFINITY and infinity mean the same.
Q3.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
Shouldn't the thread object get gced after completion of run? so the ans should be true.
Q4. can we explicitly call the constructor of an abstract class?
I'll be thankful if anyone could give the correct explanation for these.
Mamta
hi ,
In the explanation given by kavita, I want to know that whether the string references s1 & s2 get garbage collected or the string object referenced by s1 & s2.
Please clear my doubt.
thanks,
mana