Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Mock Green Exam1 Question clarification  RSS feed

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question asked in Mock Green -Exam1. I thought of working out this question but it is giving error as Type expected.
Can you tell anyone why this error i am getting. Thanks.
class sub
{
int i=9;
switch(i)
{
dafault:
System.out.println("deafult");
case 0:
System.out.println("one");
break;
case 1:
System.out.println("two");
}
}
 
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sabapathy....
ur switch code is dangling.......try putting it in the main method or in any other method & then call that method....
Aruna
 
sabapathy
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry i missed main method.After i have added main method i am getting a different error like "sub.java:9:Statement not reached.
But if i put a default block after case 1 it is not giving any error. Why? Can you explain me thanks.

class sub
{
public static void main(String args[])
{
int i=9;
switch(i)
{
dafault:
System.out.println("deafult");
case 0:
System.out.println("one");
break;
case 1:
System.out.println("two");
}
}
}
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out the spelling.
Anna S Iyer.
 
sabapathy
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh man that was a silly mistake.
Thanks anna...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!