Help coderanch get a
new server
by contributing to the fundraiser

Raji Addepalli

Ranch Hand
+ Follow
since Dec 05, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Raji Addepalli

Hi where can we practice java examples ?
Hi ! I want to take SCJP 1.4 ,Can i take this directly without taking SCJP 1.2 ,Can i refer the book Complete Java 2 Certification Study guide ? As i was prepareing for SCJP 1.2.
Hi! Daniel Congratulations.
22 years ago
public class TeSet {
public static void main(String args[]) {
int m = 2;
int p = 1;
int t = 0;
for(;p < 5;p++) {
if(t++ > m) {
m = p + t;
}
}
System.out.println("t equals " + t);
}
}
for this output is t equals 4.
Can any body explain how it is?
oops funny symbol came inbetween
that line is
C:\Java\Test7.java: 2 : Package other does not exist.
[ January 15, 2002: Message edited by: Raji Addepalli ]
hi iam getting compiler error as
C:\Java\Test7.java:2 ackage other does not exist
import other.*;
C:\Java\Test7.java: 8 : cannot resolve symbol
symbol : class other
location: package testPackage
System.out.print((testPackage.Other.hello)+"")
C:\Java\Test7.java: 9 : cannot resolve symbol
symbol : class other
location: package other
System.out.print((other.Other.hello == hello)+"")
3 errors
package testpackage;
import other.*;
class Test
{
public static void main(String args[])
{
String hello = "Hello", lo = "lo";
System.out.print((testPackage.Other.hello)+"");
System.out.print((other.Other.hello == hello)+"");
System.out.print((hello == ("Hel"+"lo")) +"");
System.out.print((hello == ("Hel"+lo))+"");
System.out.println(hello == ("Hel"+lo).intern());
}
}
class Other { static String hello = "Hello";}
public class InitClass
{
public static void main(String args[])
{
InitClass obj = new InitClass(5);
}
int m;
static int i1 = 5;
static int i2 ;
int j = 100;
int x;
public InitClass(int m)
{
System.out.println(i1 + " " + i2 + " " + x + " " +m);
}
{j = 30; i2 = 40 //Instance Initializer
static { i1++;} // Static Initializer
What will be the result of attemping to compile and run the following class?
public class TestClass
{

public static void main(String args[])
{
int i = 1;
int[] iArr = {1};
incr(i);
incr(iArr);
System.out.println("i = " +i+ " iArr[0] = " + iArr [0]);
}
public static void incr(int n) {n++; }
public static void incr(int[] n){n [ 0 ]++; }
}
Ans:i = 1 iArr[0] = 2
i got the answer but can anyone explain this?
public class TestClass
{
public static void main(String[] args)
{
String str = "111";
boolean[] bA = new boolean[l];
if( bA[0] ) str = "222";
System.out.println(str);
}
}
what will the above program print?