Java MCQs with answers Page - 3

Here, you will find a collection of MCQ questions on Java. Go through these questions to enhance your preparation for upcoming examinations and interviews.

To check the correct answer, simply click the View Answer button provided for each question.

Have your own questions to contribute? Click the button below to share your MCQs with others!

+ Add Question

A

Admin • 828.03K Points
Coach

Q. Using which annotation non visible or private method can be tested?

  • (A) @NonVisible
  • (B) @Visible
  • (C) @VisibleForTesting
  • (D) @NonVisibleForTesting

A

Admin • 828.03K Points
Coach

Q. Which one of the following is not an annotation used by Junit with Junit4?

  • (A) @Ignored
  • (B) @AfterClass
  • (C) @BeforeClass
  • (D) @Test

A

Admin • 828.03K Points
Coach

Q. Which one of the following is not ID generating strategy using @GeneratedValue annotation?

  • (A) Sequence
  • (B) Identity
  • (C) Manual
  • (D) Auto

A

Admin • 828.03K Points
Coach

Q. Which one of the following annotations is not used in Hibernate?

  • (A) @Basic
  • (B) @Entity
  • (C) @Query
  • (D) @Column

A

Admin • 828.03K Points
Coach

Q. Annotations which are applied to other annotations are called meta annotations.

  • (A) False
  • (B) True
  • (C) ---
  • (D) ---

A

Admin • 828.03K Points
Coach

Q. Automatic type conversion in Java takes place when

  • (A) Two type are compatible and size of destination type is shorter than source type.
  • (B) Two type are compatible and size of destination type is equal of source type.
  • (C) Two type are compatible and size of destination type is larger than source type.
  • (D) All of the above

A

Admin • 828.03K Points
Coach

Q. Which of the following automatic type conversion will be possible?

  • (A) short to int
  • (B) byte to int
  • (C) int to long
  • (D) long to int

A

Admin • 828.03K Points
Coach

Q. What is the output of the following program?

Code:
class A{
        public static void main(String args[]){
	        byte b;
   	        int i = 258;
	        double d = 325.59;

	        b = (byte) i;
	        System.out.print(b);

	        i = (int) d;
	        System.out.print(i);

                b = (byte) d;
                System.out.print(b);
        }
}
  • (A) 258 325 325
  • (B) 258 326 326
  • (C) 2 325 69
  • (D) Error

A

Admin • 828.03K Points
Coach

Q. Which of the following is not pre defined annotation in Java?

  • (A) @FunctionInterface
  • (B) @SafeVarags
  • (C) @Overriden
  • (D) @Deprecated

A

Admin • 828.03K Points
Coach

Q. Annotation type definition looks similar to which of the following?

  • (A) Interface
  • (B) Field
  • (C) Class
  • (D) Method

Add MCQ in this Category

If you want to share an MCQ question in this category, it's a great idea! It will be helpful for many other students using this website.

Share Your MCQ