Thursday, September 26, 2019
Static Initializer Block
Static Initializer Block Next >> Super Keyword in Java
Back<< Static keyword in Java
Questions on Interface in Java
Questions on Interface in Java
Q) A java interface can contain ————
- public static Final Variables only
- public Abstract methods
- Abstract methods(unimplemented) and implemented methods both
- public static Final Variables and abstract methods both
Answer: D
An interface can have both final variables and abstract methods.
An interface can have both final variables and abstract methods.
Q ) Which of these can be used to fully abstract a class from its implementation?
a) Objects
b) Packages
c) Interfaces
b) Packages
c) Interfaces
Answer: c
Explanation: None.
Explanation: None.
Questions on Aggregation in Java
Questions on Abstract Classes in Java
1) Abstract class must have only abstract methods. True or false?
False. Abstract methods can also have concrete methods.
2) Is it compulsory for a class which is declared as abstract to have at least one abstract method?
Not necessarily. An abstract class may or may not have abstract methods.
3) Can we use “abstract” keyword with the constructor, Instance Initialization Block, and Static Initialization Block?
No. Constructor, Static Initialization Block, Instance Initialization Block, and variables can not be abstract.
4) Why final and abstract can not be used at a time?
Because final and abstract are totally opposite in nature. A final class or method can not be modified further where as abstract class or method must be modified further.
“final” keyword is used to denote that a class or method does not need further improvements.
“abstract” keyword is used to denote that a class or method needs further improvements.
5) Can we instantiate a class which does not have even a single abstract method but declared as abstract?
No,
We can’t instantiate a class once it is declared as abstract even though it does not have abstract methods.
6) Can we declare abstract methods as private? Justify your answer?
No. Abstract methods can not be private. If abstract methods are allowed to be private, then they will not be inherited to sub class and will not get enhanced.
Subscribe to:
Posts (Atom)
Create a Digital Clock using HTML and JavaScript
Create a Digital Clock using HTML and JavaScript <! DOCTYPE html> < html > < head > ...
Followers
Search This Blog
Popular Posts
-
MG-CEIT Course Feedback Form Step1: Like below three pages for the updated course information ...
-
Software Development Tools Presentation From the moment you begin developing software, whether as a freelancer for a startup or wo...
-
Question 1 Which framework is most commonly used for unit testing in Java? JUnit TestNG Mockito Selenium Answer: JUnit Question 2 I...
-
import redis from 'redis'; // Create a Redis client with retry strategy const client = redis.createClient({ host: 'localhos...
-
const redis = require('redis'); const { promisify } = require('util'); // Create a Redis client with a connection timeout...
-
Use Request Dispatcher Servlet in creating simple Login Form We are going to create a Login Form Here. At the end of this section, y...
-
max-request-journal-entries and no-request-journal in wiremock configuration In WireMock, the request journal is a built-in feature that ke...
-
कोरोना को जाने प्रश्न (1) :- क्या कोरोना वायरस को ख़त्म किया जा सकता है उत्तर:- नहीं! कोरोना वायर...
-
Create a Digital Clock using HTML and JavaScript <! DOCTYPE html> < html > < head > ...
-
Clear cache || FlushDB || Clear Redis Cache ||Node js ||aws const express = require('express'); const redis = require('redis...