Skip to main content

Posts

Showing posts with the label Java

Java Program to implement inheritance || Java Programming Lab Exercise 2.1

  IMPLEMENTATION OF INHERITANCE What is Inheritance ? Ø   The process by which one class acquires the properties(data members) and functionalities(methods) of another class is called  inheritance . Ø   The aim of inheritance is to provide the reusability of code so that a class has to write only the unique features and rest of the common properties and functionalities can be extended from the another class. Aim:             To write a java program to implement the concept of inheritance. Procedure: Open text editor(notepad) Create a base class called “StudentBase” Declare & define department, collegeName as private data members of string datatype. Since the private data members cannot be   accessed directly, we are using public getter & setter methods   to access the private members of base class Create a derived class called “StudentDerive” that extends the base class “StudentBa...

Java Programming Lab || IMPLEMENTATION OF CLASS & OBJECTS

  IMPLEMENTATION OF CLASS & OBJECTS College.java import java.io.*; public class College {             String name;             String dept;             int age;             String place;             public College(String name, String dept,int age, String place)             {                         this.name = name;                         this.dept = dept;        ...

PROGRAMMING IN JAVA || USE INTERFACES

    II BCA -  CORE PAPER 3 PROGRAMMING IN JAVA USE INTERFACES Contents: Java Interface Need for Java interface Declaring an Interface Relationship between Interface & class Declaring Interface Constants  Java Interface ·          The interface in Java is  a mechanism to achieve  abstraction that specify what a class must do  without saying anything about how the class will do it. ·          An interface can be defined as a container that stores the methods to be implemented in the code segment. ·          An interface can have methods and variables just like the class but the methods declared in interface are by default abstract. ·          The variables declared in an interface are public, static & final by default. Need for Java interface There are mainly three re...