PRACTICE JAVA
Which of the following statements is wrong about inheritance?
a) Protected members of a class can be inherited b) The inheriting class is called a subclass c) Private members of a class can be inherited and accessed d) Inheritance is one of the features
What will be the output of the following?
a) metal b) metalmetal c) nullmetal d) The code does not compile. Answer: d) The code does not compile. Explanation The local variable chair may not have been initialized.
Which is correct about an instance variable of type String?
A. It defaults to an empty string. B. It defaults to null. C. It does not have a default value. D. It will not compile without initializing on the declaration line Answer B. It defaults
Which statement about a valid .java file is true?
a) It can only contain one class declaration. b) It can contain one public class declaration and one public interface definition. c) It must define at least one public class. d) It may define at
Which of the following declarations does not compile?
a) double num1, int num2 = 0; b) int num1, num2; c) int num1, num2 = 0; d) int num1 = 0, num2 = 0; Answer a) double num1, int num2 = 0; Explanation: Option
Which of these interfaces must contain a unique element?
a) Set b) List c) Array d) Collection Answer a) Set Explanation: A Set is a collection of items where every item is unique, and it is found in java.util package, thus option A is
Aniket Malik
CERTIFIED TUTOR/TRAINER WITH 300+ REVIEWS
My students are the presents from God to me
Do you want to learn
Programming?
Hey, I’m Aniket. I’m determined to make you one of the best developers in the history of Information technology.
My only question is, are you ready?