1. What is JDK?
Ans: JDK is an
acronym for Java Development Kit. It is a bundle of software
components that is used to develop Java-based applications includes JRE and
the compilers and tools (like JavaDoc, and Java Debugger) to create and compile
programs.
2. Which is the latest Version of Java?
Ans: Java
SE 12 release date 2019-03-19, feature contains Initial release
Java SE 12.0.1 release date 2019-04-16, feature
contains New Japanese Era Name & Security fixes
3. How can you
access the static global variable of a class?
Ans: You need
an extern keyword.
For example, we have one global variable named an in main.cpp
For example, we have one global variable named an in main.cpp
- // main.cpp
- int a = 1;
- int main()
- {
- // do
something...
- }
We want to
access the global variable an in MyClass.cpp, we should use extern.
- //
MyClass.cpp
- extern int
a;
- MyClass::MyClass()
- {
- a = 3; //
Change the global variable
- }
4. What is
Diamond Problem?
Ans: The diamond problem refers to an ambiguity that brews due to allowing
multiple inheritance. In Java, multiple inheritance is not allowed for
classes and permitted only for interfaces to eliminates this serious issue.
5. When IIB's
will be executed?
Ans: IIBs are
executed before constructors. They run each time when the object of the class
is created.
6. What is the
rule to be followed by the sub-class of an abstract class?
Ans:
- An abstract class must be declared
with an abstract keyword.
- It can have abstract and
non-abstract methods.
- It cannot be instantiated.
- It can have constructors and
static methods also.
- It can have final methods which
will force the subclass not to change the body of the method.
7. What does a
method's return type signify?
Ans: Return is
a reserved keyword in Java i.e, we can’t use it as an identifier. It is used to
exit from a method, with or without a value.
Return can be
used with methods in two ways:
- Methods returning a
value: For methods that define a return type, the return
statement must be immediately followed by the return value.
- Methods not returning a
value: For methods that don’t return a value, the return
statement can be skipped.
8. Recursion
while constructor overloading will result in compile time or run time error
Ans: Run time
error
9. What is Auto
Upcasting and Explicit Downcasting?
Ans: Converting
a subclass type to a superclass type is known as up casting.
Example-
class Super {
void Sample() {
System.out.println("method of
super class");
}
}
public class Sub extends Super {
void Sample() {
System.out.println("method of
sub class");
}
public static void main(String args[]) {
Super obj =(Super) new Sub(); obj.Sample();
}
}
Converting a
superclass type to a subclass type is known as downcasting.
Example-
class Super {
void Sample() {
System.out.println("method of
super class");
}
}
public class Sub extends Super {
void Sample() {
System.out.println("method of
sub class");
}
public static void main(String args[]) {
Super obj = new Sub();
Sub sub = (Sub) obj; sub.Sample();
}
}
10. What is
JRE?
Ans:
JRE stands for “Java Runtime Environment” and may also be
written as “Java RTE.” The Java Runtime Environment provides the
minimum requirements for executing a Java application; it consists of the Java
Virtual Machine (JVM), core classes, and supporting files.
you want to
learn the practical concept of java with hands-on experience then enroll in our Java Course in Pune
No comments:
Post a Comment