Get Job-ready: Java Course with 45+ Real-time Projects! - Learn Java
Annotations are powerful tools in the Java developer’s arsenal, adding metadata to your code to influence its behavior at compile time or runtime. Whether you’re leveraging annotations for dependency injection, framework configuration, or custom validation, a solid understanding of their capabilities is essential.
This interactive quiz will test your knowledge of core Java annotation concepts, helping you identify areas for improvement and solidify your foundation.
Quiz Summary
0 of 15 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
Results
Results
0 of 15 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
Categories
- Not categorized 0%
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- Current
- Review / Skip
- Answered
- Correct
- Incorrect
-
Question 1 of 15
1. Question
Which of the following is not a type of annotation in java ?
CorrectIncorrect -
Question 2 of 15
2. Question
class Sample {
public void display() {
System.out.println(“DataFlair”);
}
}
class Demo extends Sample {
@override
public void display()
{
System.out.println(“Override display”);
}
}
class Main {
public static void main ( string args [ ] )
{
Demo d = new Demo();
d.display();
}
}
What is the output of the program ?
CorrectIncorrect -
Question 3 of 15
3. Question
@interface
class Marker {
@MarkerDemo
public void method ()
{
Marker m = new Marker();
if(m.isAnnotationPresent)
{
System.out.println(“Annotation is present”);
}
else {
System.out.println(“Annotation is not present”);
}
public static void main( String args [ ] )
{
method();
}
}
What is the output of the program ?
CorrectIncorrect -
Question 4 of 15
4. Question
Which of the following annotations will contain no methods in it ?
CorrectIncorrect -
Question 5 of 15
5. Question
class Override {
public calculate ( int x , int y )
{
return x*y;
}
}
class Function extends Override {
@override
public void calculate( int x , int y , int z )
{
return x*y*z;
}
}
class Main {
public static void main ( String args [ ] )
{
Override o = new Function();
o.calculate(10,5,2);
}
}
What is the output of the program ?
CorrectIncorrect -
Question 6 of 15
6. Question
class Example {
public static void main ( String args [ ] )
{
@interface Marker
Marker
public void method()
{
System.out.println(‘DataFlair”);
}
method();
}
}
What is the output of the program ?
CorrectIncorrect -
Question 7 of 15
7. Question
Which of the following is not true about annotations in java ?
CorrectIncorrect -
Question 8 of 15
8. Question
class Maths {
@suppressedWarnings (“Unchecked”)
public int sum ( x , y )
{
return x+y;
}
}
class Main {
public static void main ( String args [ ] )
{
Maths m = new Maths();
System.out.println(m.sum(15,16));
}
}
What is the output of the program ?
CorrectIncorrect -
Question 9 of 15
9. Question
class Suppressed {
@SuppressedWarnings(“rawtypes”);
public void ListType()
{
List l = new List();
l.add(10);
l.add(100);
l.add(1000);
System.out.println(l);
}
}
class Main {
public static void main ( String args [ ] )
{
Suppressed s = new Suppressed();
s.ListType();
}
}
What is the output of the program ?
CorrectIncorrect -
Question 10 of 15
10. Question
Which of the following eliminates the warnings raised by the compiler ?
CorrectIncorrect -
Question 11 of 15
11. Question
class Main {
public static void main ( String args [ ] )
{
method(“DataFlair”);
}
@Marker
public void method( String a )
{
System.out.println(a);
}
}
What is the output of the program ?
CorrectIncorrect -
Question 12 of 15
12. Question
class Function {
@SupressedWarnings(“deprecated”)
public int Addition( int x , int y )
{
return x+y ;
}
}
class Main {
public static void main ( String args [ ] )
{
Function f = new Function ();
int value = f.Addition(1,2);
System.out.println(value);
}
}
What is the output of the program ?
CorrectIncorrect -
Question 13 of 15
13. Question
Which annotations are used to mark methods which should be ignored or methods that can be deleted ?
CorrectIncorrect -
Question 14 of 15
14. Question
class Exception {
Override
public void display()
{
System.out.println(“Annotation is included”);
}
}
class Main {
public static void main ( String args [ ] )
{
Exception obj = new Exception();
obj.display();
}
}
What is the error in the program ?
CorrectIncorrect -
Question 15 of 15
15. Question
@interface Multiplication
class Annotation {
public static void main ( String args [ ] )
{
method();
}
@Multiplication
void method()
{
System.out.println(32*32);
}
}
What is the output of the program ?
CorrectIncorrect
Summary:
So you’ve taken the Java Annotations Quiz and put your skills to the test! This quiz covered various annotation types, their usage scenarios, and common annotation-based features in Java.
By reviewing both your correct and incorrect answers, you can gain valuable insights into your strengths and weaknesses in this critical domain. Remember, effective learning is an ongoing process. Explore additional resources beyond the quiz to deepen your understanding.
Consider online courses, tutorials, and practice projects to further solidify your grasp of Java annotations and their applications in real-world development.
