• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Exam question on

 
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which of the following is correct ? Select all correct answers.
A. The native keyword indicates that the method is implemented in another language like C/C++.
B. The only statements that can appear before an import statement in a Java file are comments.
C. The method definitions inside interfaces are public and abstract. They cannot be private or protected.
D. A class constructor may have public or protected keyword before them, nothing else.
The Correct answers were A and B.
I disagreed with B due to the fact that packages are stated befor
the import.
Can anyone please explain why B is correct and my answer was incorrect.
 
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd have to agree with you Charlie.
 
Charlie Swanson
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for the help.
 
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think A and C are correct. Methods in an interface are public & abstract. They cannot be private, protected, static, final, etc.
The following code does not compile:
public interface test
{
private void aMethod();
}
 
Charlie Swanson
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I ran the code, and it did not compile. It did compile for abstract and public.
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A and C are both correct.
C is correct because that all methods in an Interface should be declared public. They are implicitly abstract whether you declare it or not.

Originally posted by Charlie Swanson:
Which of the following is correct ? Select all correct answers.
A. The native keyword indicates that the method is implemented in another language like C/C++.
B. The only statements that can appear before an import statement in a Java file are comments.
C. The method definitions inside interfaces are public and abstract. They cannot be private or protected.
D. A class constructor may have public or protected keyword before them, nothing else.
The Correct answers were A and B.
I disagreed with B due to the fact that packages are stated befor
the import.
Can anyone please explain why B is correct and my answer was incorrect.


 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
Only A and C are correct. Package statment comes before import so there is no confusion about B
thanks
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic