Thursday, September 26, 2019

Strings in Java

Strings in Java





1. Which of these class is superclass of String and StringBuffer class?
  • A. java.util
  • B. java.lang
  • C. ArrayList
  • D. None of the mentioned
  • Answer :B

Exceptions in Java


Exceptions in Java


Final Keyword in Java

Final Keyword in Java


Super Keyword in Java

Super Keyword in Java

Static Initializer Block

Static Initializer Block                   Next >> Super Keyword in Java

Method Overloading in Java

Method Overloading in Java



Questions on Interface in Java

Questions on Interface in Java



Q) A java interface can contain ————

  1. public static Final Variables only
  2. public Abstract methods
  3. Abstract methods(unimplemented) and implemented methods both
  4. public static Final Variables and abstract methods both
Answer: D
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
Answer: c
Explanation: None.




Interface in Java

Interface in Java

Abstract Class vs Interface in Java

Abstract Class vs Interface in Java

Abstract Classes in Java

Abstract Classes in Java

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.


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