• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Static member class-Ques from ExamLab Practice test 1

 
promila singh
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

This ques I got from ExamLab but I changed this code..My ques is even If there is no class C this still compiles fine..n don't give compiler error or any exception..why this happens paricularly with code??

promila
 
Ankit Garg
Sheriff
Posts: 9528
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code doesn't look like a mock exam question from any angle to me. There are multiple errors in the code, there is no closing curly brace for class A, the method capture is defined twice in class B, C is undefiined, capture method is not a part of class A so line ab.capture(); is also invalid. There is no way that this code can compile fine...
 
Ankit Garg
Sheriff
Posts: 9528
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If this is the code with which you are working
Then the code might compile fine, this is because earlier you might have compiled the code where there was a class named C, so your folder would contain a C.class file, if you remove that file, the program will fail to compile as it should...
 
promila singh
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you are right ankit..
there was C.class in my my folder where i also compiled this class...
thnx
one more thing...this code is from ExamLab, you then check it, its the first question in practice test 1....rest I mentioned that I modified it slightly..
promila
 
Ankit Garg
Sheriff
Posts: 9528
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
promila singh wrote:thnx
.....I modified it slightly.

But your modifications made the code uncompilable, that's why I thought its some sort of code that you created yourself. But later on when I indented the code, I saw that you forgot to close class B and A.

And please UseRealWords, and don't use words like thnx...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic