arivu mathi

Ranch Hand
+ Follow
since Jun 26, 2006
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 arivu mathi


The output is 10,0,20 can anyone explain me how?
[ September 12, 2006: Message edited by: Barry Gaunt ]
String s = new String("abc");
String s = "abc";

will the above two statements create a new string object?
what is the difference between the two statements?
Sting s = new string("abc");
a new string object is created by the above statement.

String s = "abc";
does this statement also create a new string object or it is refering to a object in the string pool?
now the code compiles fine but it's showing runtime error..why?
import java . io . * ;

class Q031 {
{


Q031()throws Exception{
try
{
throw new Exception ( ) ;
}
catch ( IOException e )
{
System . out . println ( e ) ;
}
}
}


public static void main ( String args [ ] ) throws Exception {
System . out . println ( " GodSmack " );
new Q031 ( );
}
}

why the above code is showing error?
public class Test {
String s1;
String s2 = "hello";
String s3;
Test () {
s1 = "hello";
}
public static void main(String[] args) {
(new Test ()).f();
}
{
s3 = "hello";
}
void f() {
String s4 = "hello";
String s5 = new String("hello");
assert(s1.equals(s2)); // (1)
assert(s2.equals(s3)); // (2)
assert(s3 == s4); // (3)
assert(s4 == s5); // (4)
}
}


it is not showing error in line 4. can you explain why?
i scored 719 and failed in the exam....
does the real exam is as tough as this?
i'm really worried about my score....
can we use this reference inside a static method or a class?
can we use static and native together?
can anyone explain this?
class JMM110 {
public static void main (String[] args) {
int j = 0;
do for (int i = 0; i++ < 2
System.out.print(i);
while (j++ < 2);
}}

output:1212.....can u explain this???
class B {
private String name;
public B(String name) {this.name = name;}
public String toString() {return name;}
protected void finalize() {System.out.print(name);}
}
class J {
static B bc;
static int i = 1;
static B m1(B b) {bc = b; return new B("B" + i++);}
public static void main (String[] args) {
B x = m1(new B("Ba")), y = m1(new B("Bb"));
System.out.println(", " + x + ", " + y + ", " + bc);
}}
class A {
private static int counter;
public static int getCounter(){return counter++;}
private static int innerCounter;
public static int getInnerCounter(){return innerCounter++;}
private String name;
A() {name = "A" + getCounter();}
class B {
private String name;
B() {
name = "B" + getInnerCounter();
System.out.print(A.this.name + name); // 1
}}
public static void main(String[] args) {
new A().new B(); // 2
A a1 = new A();
a1.new B(); // 3
a1.new B(); // 4
}}


can anyone explain the output plz???
public class Test {
public static void main(String [] args) {
byte [][] big = new byte [7][7];
byte [][] b = new byte [2][1];
byte b3 = 5;
byte b2 [][][][] = new byte [2][3][1][2];
//line to be inserted here
}
}
which of the following lines of code could be inserted at line 7, and still allow the code to
compile? (Choose four that would work.)
A. b2[0][1] = b;
B. b[0][0] = b3;
C. b2[1][1][0] = b[0][0];
D. b2[1][2][0] = b;
E. b2[0][1][0][0] = b[0][0];
F. b2[0][1] = big;
which book can i buy for scjp 1.4???
suncertified java programmer and developer by Kathy sierra...or is there any seperate book for programmer???
class test{
public static void main(String [] args){
Base b = new Subclass();
System.out.println(b.x);
System.out.println(b.method());
}
}

class Base{
int x = 2;
int method(){
return x;
}
}

class Subclass extends Base{
int x = 3;
int method(){
return x;
}
}


Can anyone explain the output??
class A13 {}
class A14 {
public static void main(String[] arg) {
A13[] a1 = new A13[1]; // 1
A13[][] a2 = new A13[2][1]; // 2
A13[][][] a3 = new A13[3][3][3]; // 3
System.out.print(a3[2][2][2]); // 4
a1[0] = new A13(); // 5
a2[0] = a2[1] = a1; // 6
a3[0] = a3[1] = a3[2] = a2; // 7
System.out.print(a3[2][2][2]); // 8
}}

gives run time error..
but
class A11 {public String toString() {return "A11";}}
class A12 {
public static void main(String[] arg) {
A11[] a1 = new A11[1]; // 1
A11[][] a2 = new A11[2][]; // 2
A11[][][] a3 = new A11[3][][]; // 3
a1[0] = new A11(); // 4
a2[0] = a2[1] = a1; // 5
a3[0] = a3[1] = a3[2] = a2; // 6
System.out.print(a3[2][1][0]); // 7
}}

this works fine...how?