Showing posts with label Inheritance in Java. Show all posts
Showing posts with label Inheritance in Java. Show all posts

99 Write a Java program to illustrate multilevel inheritance such that country is inherited from continent. State is inherited from country. Display the place, state, country and continent.

Code: import java.io.InputStreamReader; import java.io.BufferedReader; import java.io.IOException; class Continent {   String con...
Read More

98 Create class student having method getdata() which should accept details of student such as rollno, name and marks of 3 subject. Extend class result from student. Define a method cal() in result to calculate the total and average of marks and display it.

Code: import java.util.Scanner; class Student { // Instance Variable int rollno,m1,m2,m3; String name;    void getdata() { ...
Read More

68 What is Co-Variant return type in Java?

Code 1 : class A { A m1() { return new A(); } } class B extends A { /* Valid A m1() { return new A(); } */ ...
Read More

72 How to Create Sub packages in Java?

Code: package com.atharva; public class Demo { public static void main( String args[] ) { System.out.println(" Sub Pac...
Read More

71 How to Create Program on Package in Current Location?

Code : package codingatharva; public class PackageDemo { public static void main( String args[] ) { System.out.println(...
Read More