Code: // Program on hierarchical inheritance class Course { String insName = "Coding Atharva"; } class Java extends Co...
Read More
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
77 Program on Up-casting & Down-casting in Java?
Code: import java.util.Scanner; class A { int a = 111 ; static int b =222; void m1() { System.out.println(" Super...
Read More
74 How to create Package in Different Location & How to Communicate?
Code: package ca; public class Test { public static void main(String args[] ) { System.out.println(" this is a package p...
Read More
73 How to Communicating with Different Locations Packages in a Single Program in Java?
A Code: package ram; public class A { public static int a = 111; } B Code: package sam; public class B { publ...
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
Subscribe to:
Posts (Atom)