• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Doubt from javaprepare.com

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Language fundamentals tutorial question no. 17
Which of the following are legal Java programs. Select all the correct answer?
A.// The comments come before the package
package pkg;
import java.awt.*;
class C{};
B.package pkg;
import java.awt.*;
class C{};
C.package pkg1;
package pkg2;
import java.awt.*;
class C{};
D.package pkg;
import java.awt.*;
E.import java.awt.*;
class C{};
F.import java.awt.*;
package pkg;
class C {};
Answers he gave: A, B, D, E
My doubt is Do we need semicolon( after class C{};
please someone tell me.
Thank you all in advance

Regards
VR
 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are right. A semi-colon is NOT required. But it does not hurt either. A semi-colon by itself is an empty statement. It is not illegal.
 
Amateurs built google. Professionals built the titanic. We can't find the guy that built this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic