JAVA MCQs with answers Page - 3

Dear candidates you will find MCQ questions of JAVA here. Learn these questions and prepare yourself for coming examinations and interviews. You can check the right answer of any question by clicking on any option or by clicking view answer button.
Share your questions by clicking Add Question

M

Manisha Agrawal • 9.34K Points
Tutor III

Q. Determine output:

Code:
class A{
        public static void main(String args[]){
	        int x;
 	        x = 10;
	        if(x == 10){
		        int y = 20;
		        System.out.print("x and y: "+ x + " " + y);
		        y = x*2;
	        }
	        y = 100;
	        System.out.print("x and y: " + x + " " + y);
        }
}
  • (A) 10 20 10 100
  • (B) 10 20 10 20
  • (C) 10 20 10 10
  • (D) Error

M

Manisha Agrawal • 9.34K Points
Tutor III

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

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

M

Manisha Agrawal • 9.34K Points
Tutor III

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

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

M

Manisha Agrawal • 9.34K Points
Tutor III

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

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

M

Manisha Agrawal • 9.34K Points
Tutor III

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

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

M

Manisha Agrawal • 9.34K Points
Tutor III

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

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

M

Manisha Agrawal • 9.34K Points
Tutor III

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

M

Manisha Agrawal • 9.34K Points
Tutor III

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

M

Manisha Agrawal • 9.34K Points
Tutor III

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

K

Kirti • 10.45K Points
Tutor II

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

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

Loding content...

Download our easy to use, user friendly Android App from Play Store. And learn MCQs with one click.

Image

Login

Forgot username? click here

Forgot password? Click here

Don't have account? Register here.