Check out all the Java daily quiz questions at https://www.javaguides.net/p/java-daily-quiz.html.
Check out 200+ video tutorials on my YouTube channel at https://www.youtube.com/c/javaguides.
Quiz 3 - What will be the output of the following Java program?
class Base {
public void test() {
}
}
class Base1 extends Base {
public void test() {
System.out.println("Base1");
}
}
class Base2 extends Base {
public void test() {
System.out.println("Base2");
}
}
class Test {
public static void main(String[] args) {
Base obj = new Base1();
((Base2) obj).test(); // CAST
}
}
Answer
d) The program will result in an exception (ClassCastException).
Check out all the Java daily quiz questions at https://www.javaguides.net/p/java-daily-quiz.html.
Check out 200+ video tutorials on my YouTube channel at https://www.youtube.com/c/javaguides
Continue Learning with Java Guides
Want to take your programming skills to the next level? Explore my practical Udemy courses on Java, Spring Boot, Microservices, Full-Stack Development, Docker, and Generative AI. You can also follow my structured learning roadmaps to become a professional developer.
By Ramesh Fadatare - Udemy Instructor Partner
Comments
Post a Comment
Leave Comment