0

Simple Java Quiz

Description: Simple Java Quiz
Number of Questions: 10
Created by:
Tags: java
Attempted 0/10 Correct 0 Score 0

Which methods can access to private attributes of a class

  1. A. Only Static methods of the same class

  2. B. Only instances of the same class

  3. C. Only methods those defined in the same class

  4. D. Only classes available in the same package.


Correct Option: C
  1. A. An instance of a class is an object

  2. C. Object is the super class of all other classes

  3. D. Objects do not permit encapsulation


Correct Option: C

What is an aggregate object?

  1. A. An object with only primitive attributes

  2. C. An instance which has other objects

  3. D. None of the above


Correct Option: B
  1. B. void returns no data type.

  2. C. void is not supported in Java

  3. D. None of the above


Correct Option: A

A class can have many methods with the same name as long as the number of parameters or type of parameters is different. This OOP concept is known as

  1. A. Method Invocating

  2. B. Method Overriding

  3. C. Method Labeling

  4. D. Method Overloading


Correct Option: D

After the following code fragment, what is the value in fname?String str;int fname;str = ";Foolish boy.";fname = str.indexOf("fool");

  1. A. 0

  2. B. 2

  3. C. -1

  4. D. 4


Correct Option: C
  1. A. Compile and display “Equal”

  2. B. Compile and display “Not Equal”

  3. C. Cause a compiler error

  4. D. Compile and display NULL


Correct Option: A

Which of the following is not a return type?

  1. A. boolean

  2. B. void

  3. C. public

  4. D. Button


Correct Option: C
  1. A. protected

  2. B. extends Throwable

  3. C. implements Throwable

  4. D. serializable


Correct Option: B
- Hide questions