This week's book giveaway is in the Java in General forum.
We're giving away four copies of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 and have ishori Sharan & Adam L Davis on-line!
See this thread for details.
Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!

Patel a

Greenhorn
+ Follow
since Aug 23, 2000
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 Patel a

What will happen if you compile/run the following code?

1: public class Q21
2: {
3: int maxElements;
4:
5: void Q21()
6: {
7: maxElements = 100;
8: System.out.println(maxElements);
9: }
10:
11: Q21(int i)
12: {
13: maxElements = i;
14: System.out.println(maxElements);
15: }
16:
17: public static void main(String[] args)
18: {
19: Q21 a = new Q21();
20: Q21 b = new Q21(999);
21: }
22: }
A) Prints 100 and 999.
B) Prints 999 and 100.
C) Compilation error at line 3, variable maxElements was not initialized.
D) Compillation error at line 19.
The correct answer is D
Could someone explain why.
thanks in adv
amisha
Can someone help me on how to make an applet, a trusted applet.
21 years ago
What is JLS and where can i find it?
Congrads Vivek,
May god bless you and you family
regards
amisha
I am trying to complie the following program:
class Top{
int i, j;
void bar(){
SomeClass sc=new SomeClass();
}
class SomeClass{
int k;
void foo(){
System.out.println("This is a nested inner class");
}
}
}
class someOther extends Top{
public static void main(String arg[])
{
Top.SomeClass myc= new Top.SomeClass();
myc.foo();
}
}
I am getting a compile time error: No enclosing instance of class Top is in scope; an explicit one must be provided when creating inner class Top. SomeClass, as in "outer.new Inner()" or "outer.super()".
Top.SomeClass myc= new Top.SomeClass();
If I declare the inner class SomeClass static it will work.
I would like to know why this will not compile.
I would really appreciate it if someone could help me.
21 years ago
Stephanie,
Thank you for the example, it was very simple and easy to understand.
I wasn't sure about the concept and this example clarified the concept for me


[This message has been edited by Patel a (edited August 30, 2000).]
21 years ago
I am not very clear on the difference between Inheritance and Aggregation. I know inheritance has a is-a relationship between superclass and subclass, and the other has a has-a relationship.
But I am not very clear on the concept.
Please help
21 years ago
Thank for your suggests. I actually thought about it and did come up with a solution.
Milind Kulkarni, I agree with you advice. It took some time, but I did come up with a solution.
21 years ago
I was trying to do the assignments in the cattle drive.
The question is
"Write a program that will read in a number from 0 to 99 and spell out that number. The program must also report any values that are out of range.
In other words, I want to type
java Say 22
and see
twenty-two"
How would i go about writing this program.
please give some guidelines

21 years ago
What is a concrete class?
Can someone please help?
21 years ago
I have the following error: Exception in thread "main" java.lang.NoClassDefFoundError: Test
Test is the name of my java file.
I have no idea with it means.
so please help
21 years ago