sunil kathuria

Greenhorn
+ Follow
since Jun 06, 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 sunil kathuria

thanks vanitha and chandrashekar
i had given mock exam of jchq,rhe,mughal,maaji,G04java
i was very confident in i/o .but got 80% .
in threading i was not confident as due to lack of material
for threading.
if u need any type of help then mail me

sunil
22 years ago
dear pals

thanks for ur quick replies and good wishes.
i am not satisfied with my result as i was expecting more
than 90% but not succeeded.i got around 8 questions on
threading out of which 3 are very typical,4to5 questions
from i/o (constructors based). 7-8 from AWt .
overall paper was not so tough but i am failed to
achieve my target.
all the best to all of u
sunil

22 years ago
hi ranchers
one more exam has been introduced at http://www.go4java.20m.com .it is little
tougher than actual exam,but u need not
have to worry,i have talked to the auther
about this complexity who is very good
friend of mine,he only tried to convey
his experience .In every question
u will find a new point.i have also attempted
this mock exam ,only got 71% as compared
to other mock exams in which i was getting
more than 85%.
so just attempt the exam,dont worry about
the result,real exam will be simpler.
and pl. correct two mistakes in exam
1) in Q no.36
correct line 9--> Runnable r = new Q58();
to -->Runnable r = new Q36();
2)in Q no.53
correct option no.3 -->
Program will compile correctly and print World when executed

to -->Program will compile correctly and print owo when executed

if u are interested then logon to
http://www.go4java.20m.com
sunil
hi ranchers
i found a very good mock exam
if u are intersted then logon to http://www.go4java.20m.com/
sunil
class Lang2
{
public static void main(String args[])
{
//CASE 1--------------------------->not equal
if("String".replace('g','G') == "String".replace('g','G'))
System.out.println("Equal");
else
System.out.println("Not Equal");
//CASE 2--------------------------->equal
if("String".trim() == "String".trim()) //line 1
System.out.println("Equal");
else
System.out.println("Not Equal");
}
}

My question is ,in both cases new objects have been
created then why it is not displaying "not equal" in
both cases.

pl.give me a good answer
sunil
pl. read the option 3 again
it says that --> causes no error and value printed on the screen is one more than Integer.MAX_VALUE
that means if we add 1 to Integer.MAX_VALUE
or System.out.println((Math.abs(Integer.MAX_VALUE+1));
which gives -2147483648 which is less than zero
so pl. confirm me the right answer

sunil
What will be the result of attempt to compile and the run the following code
1. public class ADirtyOne {
2. public static void main(String args[]) {
3. System.out.println(Math.abs(Integer.MIN_VALUE));
4. }
5. }
Select one correct answer
a) causes compilation error
b) causes no error and value printed on the
screen is less than zero
c) causes no error and value printed on the screen is one more
than Integer.MAX_VALUE
d) will throw runtimeexception
answer given is --->b
i think option c is also right as (Integer.MAX_VALUE+1) will produce
-2147483648 which is less than zero
pl.confirm me the right answer and correct me if wrong
thanks in adv.
sunil
this question is from mock javacaps ceritification
is it true or false
dialog box is pop up window ?
answer is yes.
but i think it should be false as dailog box has not any relation
with pop up window.
please confirm and correct if wrong
sunil
following question is from mock exam -SARGA.com
At what point is the object anObj available for garbage collection.
01: public class Base{
02:
03: private void test() {
04:
05: if(true) {
06: String anObj = "sample";
07: String locObj = anObj;
08: anObj.trim();
09: anObj = null;
10: locObj.trim();
11: }
12: }
13:
14: static public void main(String[] a) {
15: new Base().test();
16: }
17:
18: }
Select most appropriate answer
a) After line 7
b) After line 8
c) After line 9
d) After line 10
e) After line 11

answer given is -- >e
but whereever i think it should be c as when we set "anObj" to null it will be available for gc.
pl. tell me the right answer and correct me if wrong
thanks in adv.
sunil
hello bill
quote
===============================================================
Here is the way I look at it:
---------
String s1,s2,s3,s4;
s1 = "Hello";//1 - no new String, "Hello" is a literal constant String created when the class file is loaded. Same for Pal.
s2 = s1;//2 - no new String
s3 = s2 + "Pal";//3 - new String due to combining two literal constants
s4 = s3;//4 - no new String
--- So executing the code creates only one new object.
Bill
===============================================================
in ur reply u have told that on line 1,3 no new String
object is created as these are literal constants
but i have read in following books a new object will
be created when we use this style
1) comp.ref(4th edition) by patrick naughton-page 345
art.--String literals--> it is written
" for each string literal in ur program, java automatically
constructs a new String object.thus u can use a string
literal to intialize a String object..........."
2) A Programmers's gude to java certification By Khalid A.Mughal

--page 307 -art. "creating and intilaizing Strings"
it is written--
"A String literal is implemented as an anonymous String object
java optimizes handling of String literals. only one anonymous
String object is shared by all String literals............"
so pl. look into these books and clear me what is right
and pl. correct me if i am wrong.
thanks
Sunil
ok i am starting new thread--casting problem(new)!!
pl. look.
sunil
interface If1
{
}
class A
{
}

class B extends A
{
}
class C extends A implements If1
{
}
public class castingProblem
{
public static void main(String args[])
{
If1 ob1 = new C();
B ob2 = (B) ob1; //Line2--> legal at compile and illegal at run-time
C ob3 = new C();
B ob4 = (B)ob3; //Line4-> illegal both at compile and run-time
}
}
my question is --> at line 2 and line4 i am assigning object
of C to Object of B .as line 2 is legal at compile time why
line 4 is not legal at compile time.
i compiled this code on jdk1.2.2
pl. throw light on this
sunil
pl. solve my problem. till now i have not got the descriptive
answer
pl. help
sunil
q-1)
=====
import java.io.*;
class Super
{
int methodOne( int a, long b ) throws IOException
{ // code that performs some calculations
}
float methodTwo( char a, int b )
{ // code that performs other calculations
}
}
public class Sub extends Super
{
}
which of the following are legal method declarations to
add to the class Sub?
Assume that each method is the only one being added.
a) public static void main( String args[] ){}
b) float methodTwo(){}
c) long methodOne( int c, long d ){}
d) int methodOne( int c, long d ) throws ArithmeticException{}
e) int methodOne( int c, long d ) throws FileNotFoundException{}
the answer given are ---> a,b,e
but according to me 'd' is also valid method if we don't
declare 'e' in sub class so in this case we can choose
either d or e.
so pl.tell me the right answers and correct me if wrong
q-2)
=====
If raf is a RandomAccessFile, what is the result of compiling
and executing the following code?
raf.seek( raf.length() );
a) The code will not compile.
b) An IOException will be thrown.
c) The file pointer will be positioned immediately before the
last character of the file.
d) The file pointer will be positioned immediately after the
last character of the file.
answer given is -->d
it is little bit confusing me . i think ,answer may be 'a' as
"seek(long i)" method throws IoException and i know if a method
may throws Checked exception then it should be in try-catch block
or declared in throws clause of method.in this case there is no
try-catch block . so the code should not compile
d is correct if the code will be written in try-catch block.
pl. tell me the right answer

thanks in adv.
sunil
sorry there is problem in hierarchy diagram

only class C is implementing interface If1 not class B
pl consider this hierachy
class A
!
!-->class B
!
!
!-->class C implements If1
pl. answer according to above hierrachy
sunil

[This message has been edited by sunil kathuria (edited June 27, 2001).]
[This message has been edited by sunil kathuria (edited June 27, 2001).]
[This message has been edited by sunil kathuria (edited June 27, 2001).]
[This message has been edited by sunil kathuria (edited June 27, 2001).]