Ajay Kumar Rana

Greenhorn
+ Follow
since Feb 27, 2008
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 Ajay Kumar Rana

Can we instantiate a nested static inner class with the help of an instance of outer class. For example

public class Exercise1 {
public static void main(String[] args){
MyOuter1 m = new MyOuter1();
MyOuter1.MyInner mi = m.new MyInner(); // is it correct???
}
}
class MyOuter1{
public static class MyInner{public static void foo(){}}
}

Why or why not?
10 years ago
Hi,

What is ExceptionInInitializerError ? when it is thrown?
10 years ago
Is NumberFormatException subclass of FileNotFoundException ? where can i get the information that one exception class is subclass of another or not.
10 years ago

Originally posted by Peter Chase:
Please use code tags in any future posts. Your code is practically unreadable without them.

In Java (and C, C++ etc.) it is legal to ignore the return value of a method. Personally, I wish it wasn't, but it's a small point.



can you please let me know how to make my code more readable. I didn't get the point of using code tags.
10 years ago
in this code

public class Knowing{
static final long tooth = 343L;
static long doIt(long tooth){
System.out.println(++tooth + "");
return ++tooth;

}
public static void main(String[]args){
System.out.println(tooth + "");
final long tooth = 340L;
2 new Knowing().doIt(tooth);
System.out.println(tooth);
}
}

the line marked as 2 should give compilation error because the value returned by the doIt() method is not assigned to any variable.But this is not giving any error, the code is running successfully.Why?
10 years ago
for the code below

public class Dims{
public static void main(String[] args){
int [][] a = { {1,2}, {3,4} };
int [] b = (int []) a[1];
Object o1 = a;
int [][] a2 = (int[][])o1;
int[] b2 = (int[])o1;
System.out.println(b[1]);
}
}

an exception is thrown at runtime. Why the error is not thrown at compile time although o1 is two dimensional array reference and b2 is one dimensional.I am not able to grasp this concept.Please explain.
10 years ago
Hi,
I want to know when we extend a class then Do the variables are also inherited to the subclass or not?
what i exactly want to know is if

class A{}
class B extends A{}

then will the variables of class A be present in class B or not (i want to know about both types of variables static and non-static).Explain.
10 years ago
are Has-a relationships always tightly coupled ? why or why not.
10 years ago
All methods in a class are implicitly passed a this parameter when called.

Is this true or false ? why or why not.
10 years ago
Hi,

The question is:

Which one of the following are not valid character contants? [8]
Select any two.
(a)char c = '\u00001' ;
(b)char c = '\101';
(c)char c = 65;
(d)char c = '\1001' ;

and the answers are (a) and (d) . The thing is that i am not clear with the unicode notation and this tyoe character constants.Please suggest me a link on which i can read and understand the explanations of this answer and also "unicode".
10 years ago
Hi,
I have typed this statement in eclipse

char \u0061 = �a�;

and it is not giving any error . But it has to give error because the identifier name is starting with "\" which is illegal, please give me explanation about this identifier naming.
10 years ago
Hi,
Is this declaration legal char a = �\u0061�; if not why?
10 years ago
Hi,
I want to know about all prefixes which we can use in the names of methods used in java beans.Like get, is,set etc.
10 years ago