Questions
Which methods can access to private attributes of a class
- A. Only Static methods of the same class
- B. Only instances of the same class
- C. Only methods those defined in the same class
- D. Only classes available in the same package.
Which of the following statements is false about objects
- A. An instance of a class is an object
- C. Object is the super class of all other classes
- D. Objects do not permit encapsulation
What is an aggregate object?
- A. An object with only primitive attributes
- C. An instance which has other objects
- D. None of the above
What is the meaning of the return data type void?
- B. void returns no data type.
- C. void is not supported in Java
- D. None of the above
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
- A. Method Invocating
- B. Method Overriding
- C. Method Labeling
- D. Method Overloading
After the following code fragment, what is the value in fname?String str;int fname;str = ";Foolish boy.";fname = str.indexOf("fool");
- A. 0
- B. 2
- C. -1
- D. 4
The code snippetif( "Welcome".trim() == "Welcome".trim() )System.out.println("Equal");elseSystem.out.println("Not Equal");will
- A. Compile and display “Equal”
- B. Compile and display “Not Equal”
- C. Cause a compiler error
- D. Compile and display NULL
Which of the following is not a return type?
- A. boolean
- B. void
- C. public
- D. Button
The class java.lang.Exception is
- A. protected
- B. extends Throwable
- C. implements Throwable
- D. serializable
Consider the following code snippet. What will be assigned to the variable fourthChar, if the code is executed? String str = new String(“Java”); char fourthChar = str.charAt(4);
- A. ‘a’
- B. ‘v’
- C. throws StringIndexOutofBoundsException
- D. null characater