Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
42 views

Quiz About Java Abstract Class and Interface

Uploaded by

mostafa nasser
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views

Quiz About Java Abstract Class and Interface

Uploaded by

mostafa nasser
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Java Abstract Class and Interface Trending in News View More

105 Funny Things to Do to Make


Question 1 Someone Laugh
Best PS5 SSDs in 2024: Top Picks for
Expanding Your Storage
Which of the following statement(s) with regard to an abstract class in
Best Nintendo Switch Controllers in
JAVA is/are TRUE ? I. An abstract class is one that is not used to create
2024
objects. II. An abstract class is designed only to act as a base class to be
#geekstreak2024 – 21 Days POTD
inherited by other classes. Challenge Powered By Deutsche Bank
Full Stack Developer Roadmap [2024
Only I
Updated]
Only II

Neither I nor II

Both I and II

Discuss it

Question 1 ‒ Explanation
Abstract data class is not used to create objects in Java and it is design
ed only to act as a base class to be inherited by other classes. Both Stat
ement are correct. For more information Refer:Abstract Classes in Java
Option (D) is correct.

Question 2

We can make a class abstract by

Declaring it abstract using the virtual keyword

Making at least one member function as virtual function

Making at least one member function as pure virtual function

Making all member function const

Discuss it

Question 2 ‒ Explanation
An abstract class is a class that is designed to be specifically used as
a base class. An abstract class contains at least one pure virtual funct
ion. A pure virtual function can be declared by using a pure specifier
( = 0 ) in the declaration of a virtual member function in the class de
claration. Option (C) is correct.

Question 3

Which of the following is used to make an Abstract class?

Making atleast one member function as pure virtual function

Making atleast one member function as virtual function

Declaring as Abstract class using virtual keyword

Declaring as Abstract class using static keyword

Discuss it

Question 3 ‒ Explanation
Making atleast one member function as pure virtual function is the met
hod to make abstract class. For more information on Abstract Class Ref
er:Pure Virtual Functions and Abstract Classes in C++ Option (A) is corre
ct.

Question 4

Type IV JDBC driver is a driver

which is written in C++

which requires an intermediate layer

which communicates through Java sockets

which translates JDBC function calls into API not native to DBMS

Discuss it

Question 4 ‒ Explanation
JDBC type 4 driver,works directly by connecting to the database serv
er through socket connections and converts JDBC calls to vendor-sp
ecific database protocols.These drivers don\'t require any intermedia
te layer. So, option (C) is correct.

Question 5
Predict the output of the following program.

Java

abstract class demo


{
public int a;
demo()
{
a = 10;
}

abstract public void set();

abstract final public void get();

class Test extends demo


{

public void set(int a)


{
this.a = a;
}

final public void get()


{
System.out.println("a = " + a);
}

public static void main(String[] args)


{
Test obj = new Test();
obj.set(20);
obj.get();
}
}

a = 10

a = 20

Compilation error

Discuss it

Question 5 ‒ Explanation
Final method can’t be overridden. Thus, an abstract function can’t b
e final.

Question 6

Which of the following is FALSE about abstract classes in Java


If we derive an abstract class and do not implement all the abstract
methods, then the derived class should also be marked as abstract
using \'abstract\' keyword

Abstract classes can have constructors

A class can be made abstract without any abstract method

A class can inherit from multiple abstract classes.

Discuss it

Question 7

Which of the following is true about interfaces in java.

1) An interface can contain following type of members.


....public, static, final fields (i.e., constants)
....default and static methods with bodies

2) An instance of interface can be created.

3) A class can implement multiple interfaces.

4) Many classes can implement the same interface.

1, 3 and 4

1, 2 and 4

2, 3 and 4

1, 2, 3 and 4

Discuss it

Question 7 ‒ Explanation
Answer: (A)

Explanation: The instance of an interface can't be created because it a


cts as an abstract class.

Quiz of this Question

You have completed 7/7 questions .


Your accuracy is 57%.

Last Updated : Mar 22, 2024


Take a part in the ongoing discussion View All Discussion

Company Languages DSA Data Web Python


About Us Python Data Science & Technologies Tutorial
Corporate & Legal Java Structures
Communications Address:- In Media
ML HTML Python
A-143, 9th Floor, Sovereign C++ Algorithms CSS Programming
Data Science
Corporate Tower, Sector- Contact Us PHP DSA for JavaScript Examples
With Python
136, Noida, Uttar Pradesh Advertise with GoLang Beginners TypeScript Python Projects
(201305) | Registered Data Science
us SQL Basic DSA ReactJS Python Tkinter
Address:- K 061, Tower K, For Beginner
GFG Corporate R Language Problems NextJS Web Scraping
Gulshan Vivante Apartment, Solution
Machine
Sector 137, Noida, Gautam Android DSA Bootstrap OpenCV Tutorial
Learning
Buddh Nagar, Uttar Pradesh, Placement Tutorial Roadmap Web Design Python Interview
ML Maths
201305 Training Tutorials Top 100 Question
Data
Program Archive DSA Django
Visualisation
GeeksforGeeks Interview
Pandas
Community Problems
NumPy
DSA
NLP
Roadmap
Deep Learning
by
Sandeep
Jain
All Cheat
Sheets

Computer DevOps System Inteview School GeeksforGeeks


Science Git Design Preparation Subjects Videos
Operating Linux High Level Competitive Mathematics DSA
Systems AWS Design Programming Physics Python
Computer Docker Low Level Top DS or Algo Chemistry Java
Network Kubernetes Design for CP Biology C++
Database Azure UML Company-Wise Social Science Web Development
Management GCP Diagrams Recruitment English Data Science
System DevOps Interview Process Grammar CS Subjects
Software Roadmap Guide Company-Wise Commerce
Engineering Design Preparation World GK
Digital Logic Patterns Aptitude
Design OOAD Preparation
Engineering System Puzzles
Maths Design
Software Bootcamp
Development Interview
Software Questions
Testing

@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved

You might also like