Class 12
Information Technology (802)
351 questions available
Refine
All questions
351 resultsAn object is:
Show answer
In a class Book with data members Title, Author, Publisher and methods display() and getPrice(), the data members are also called:
Show answer
A special method used to initialize the data members of a class when an object is created is called a:
Show answer
Which of these statements about a Java constructor is TRUE?
Show answer
If a class defines only a parameterized constructor, what happens when you try to create an object without arguments, e.g., new Book()?
Show answer
A constructor that initializes all data members with default values and takes no parameters is called a:
Show answer
Which keyword is used to create a new object of a class in Java?
Show answer
Which operator is used to access data members and method members of an object?
Show answer
Why do all Java classes have access to methods like hashCode() and wait() even without defining them?
Show answer
Which access modifier makes a data member or method visible ONLY within its own class?
Show answer
By default (if no access modifier is specified), what is the visibility of a class member in Java?
Show answer
A method that returns the value of a private data member is called a:
Show answer
A method that allows controlled modification of a private data member's value (possibly with validation) is called a:
Show answer
What is the main benefit of using getter and setter methods instead of allowing direct public access to data members?
Show answer
Once a data member is declared private, it can still be accessed directly from outside the class using the dot operator.
Show answer
A constructor is called explicitly by the programmer using a special 'construct' statement.
Show answer
What is the difference between a Class and an Object? Give an example.
Show answer
Why is a constructor used in a class?
Show answer
Design a Java class 'Book' with private data members Title, Author, Publisher, Genre (all String) and Price (double). Include a parameterized constructor, a getter and setter for Price (the setter should not allow price below 100), and a display() method.
Show answer
Which keyword is used to bring a prebuilt Java class into a program for use?