In Java programming, Which of the following statements are true? there may be mo
ID: 3851096 • Letter: I
Question
In Java programming, Which of the following statements are true? there may be more than one correct option slected from the options below.
1. If you compile an interface without errors, a .class file is created for the interface.
2. If you compile a class without errors but with warnings, a .class file is created.
3. If you compile a class with errors, a .class file is created for the class.
4. If you compile an interface without errors, but with warnings, a .class file is created for the interface.
Explanation / Answer
For compliling java files ,do remember following simple rule :
With this knowledge ,evaluation of given option is as :
1. If you compile an interface without errors, a .class file is created for the interface.
Interface is also a java file ,it would also generate a class file with name of interface as Class file name ,after
its compilation . so this statement is correct .
2. If you compile a class without errors but with warnings, a .class file is created.
Class file with java extension would also generate a Class file with name of Class after its compilation ,so this
statement is also correct.
3. If you compile a class with errors, a .class file is created for the class.
A class with errors would not compile as it would generate errors and so a class file is not generated . So ,this
statement is not correct .
4. If you compile an interface without errors, but with warnings, a .class file is created for the interface.
A class file with warnings would get compiled and will generate a Class file with name as the Class inside the class file . So this statement is also correct.
So , for this question ,options 1, 2 and 4 are correct .
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.