Get Job-ready: Java Course with 45+ Real-time Projects! - Learn Java
Abstraction is a fundamental concept in Object-Oriented Programming (OOP) that allows you to focus on the “what” rather than the “how” of things. By hiding unnecessary details and exposing only essential functionalities, abstraction simplifies code, improves maintainability, and promotes code reusability.
This quiz on DataFlair will test your understanding of abstraction in Java and help you solidify your grasp of this critical concept. Let’s test your knowledge.
Time limit: 0
Quiz Summary
0 of 15 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
Which of the following concepts in OOPS is used to present only the required features to the
user?
Correct
Incorrect
Question 2 of 15
2. Question
Which of the following is the correct syntax of the abstract class ?
Correct
Incorrect
Question 3 of 15
3. Question
abstract class Organism {
public void Sound():
public void Sense();
}
class Human implements Organism {
void Sound() {
System.out.println(“Humans speaks languages”);
}
void Sense() {
System.out.println(“Humans have 6 senses”);
}
};
class Dog implements Organisms {
void Sound() {
System.out.println(“Dog Barks”);
}
void Senses {
System.out.println(“Dogs have 5 senses”);
}
};
class Main {
public static void main ( String args [ ] )
{
Organism h = new Human();
h.Sound();
h.Sense();
}
}
Correct
Incorrect
Question 4 of 15
4. Question
Which of these is used to achieve 100% abstraction in Java ?
Correct
Incorrect
Question 5 of 15
5. Question
abstract class Area {
}
class Circle implements Area {
void area (float r) {
System.out.println(Math.Pi*r*r);
}
};
class main {
public static void main ( String args [ ] )
{
Area a = new Circle();
a.area(3);
}
}
Correct
Incorrect
Question 6 of 15
6. Question
abstract class Demo {
public void display();
}
class RealityShows extends Demo {
void display(String text) {
System.out.println(text);
}
};
class Webseries extends Demo {
void display(String text) {
System.out.println(text);
}
};
class Main {
public static void main (String args [ ] )
{
Demo d = new RealityShows();
Demo d = new Webseries();
d.display(“Telecasted in a pattern.”);
}
}
Correct
Incorrect
Question 7 of 15
7. Question
Which of the following is not true about Abstract classes ?
Correct
Incorrect
Question 8 of 15
8. Question
abstract class Functionality {
}
class One extends Functionality {
void print() {
System.out.println(“One is an extended class of Functionality”);
}
}
class Main {
public static void main ( String args [ ] )
{
Functionality o = new One();
o.display();
}
}
Correct
Incorrect
Question 9 of 15
9. Question
abstract class Example {
void displayText();
}
class Demo extends Example {
void method() {
System.out.println(“Method body is executed.”);
}
};
class Main {
public static void main ( String args [ ] )
{
Example e = new Demo();
e.method();
}
}
Correct
Incorrect
Question 10 of 15
10. Question
Which of the following keywords is used to declare abstract class ?
Correct
Incorrect
Question 11 of 15
11. Question
abstract class One {
void calculate();
}
class Two extends One {
void calculate(int a) {
System.out.println(a+a);
}
}
class Three extends One {
void calculate(int a) {
System.out.println(a*a);
}
}
class Main {
public static void main ( String args [ ] )
{
One obj1 = new Two();
obj1.calculate(2);
One obj2 = new Three();
obj2.calculate(2);
}
}
Correct
Incorrect
Question 12 of 15
12. Question
class Sample {
abstract void method();
}
class First extends Sample {
Abstract void method() {
System.out.println(“First abstract method”);
}
}
class Main {
public static void main ( String args [ ] )
{
Sample object = new First();
object.method();
}
}
Correct
Incorrect
Question 13 of 15
13. Question
Which of the following classes contains a default parameter ?
Correct
Incorrect
Question 14 of 15
14. Question
Which of the following programs contain abstract classes ?
Correct
Incorrect
Question 15 of 15
15. Question
abstract class One {
public void method();
}
class Two extends One {
void method() {
System.out.println(“First extended class is executed”);
}
};
class Three extends One {
void method() {
System.out.println(‘Second extended class is executed”);
}
};
class Main {
public static void main ( String args [ ] )
{
One o = new Two();
o.method();
One o = new Three();
}
}
Correct
Incorrect
Summary:
Ready to put your knowledge of abstraction in Java to the test? This quiz by DataFlair provides a series of multiple-choice questions designed to assess your understanding of key abstraction principles.
Whether you’re a beginner or a seasoned Java programmer, this quiz can be a valuable tool to identify areas for improvement and solidify your mastery of abstraction concepts.
By attempting the quiz, you’ll gain insights into essential topics such as abstract classes, interfaces, and the benefits of using abstraction in your Java applications.
Your 15 seconds will encourage us to work even harder Please share your happy experience on Google
DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.