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!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic