Skip to main content

four methods overload these methods

Write a program in java which has the following classes and methods: 
Class : OverloadDemo
Methods : test()
Declare four methods with the same name “test()” and overload these methods




class OverloadDemo{ 
public void test(){ 
System.out.println("It's a test method for null."); 
public void test(int n){ 
System.out.println("It's a test method for displaying the int value "+n); 
public void test(double d){ 
System.out.println("It's a test method for displaying the double value "+d); 
public void test(String s){ 
System.out.println("It's a test method for displaying the String "+s); 
class overClass{ 
public static void main(String[] args) { 
OverloadDemo old = new OverloadDemo(); 
old.test(); 
old.test(12); 
old.test(25.35); 
old.test("Subham"); 
}


OUTPUT:

It's a test method for null.
It's a test method for displaying the int value 12
It's a test method for displaying the double value 25.35
It's a test method for displaying the String Subham


Comments

Popular posts from this blog

Joins in DBMS

DBMS Joins: Inner, THETA, Outer, Equi Types of Join Operations Join in DBMS is a binary operation that allows you to combine join product and selection in one single statement. The goal of creating a join condition is that it helps you to combine the data from two or more DBMS tables. The tables in DBMS are associated using the primary key and foreign keys. Types of Join There are mainly two types of joins in DBMS: Inner Joins: Theta, Natural, EQUI Outer Join: Left, Right, Full Inner Join Inner Join is used to return rows from both tables which satisfy the given condition. It is the most widely used join operation and can be considered as a default join-type An Inner join or equijoin is a comparator-based join which uses equality comparisons in the join-predicate. However, if you use other comparison operators like “>” it can’t be called equijoin. Inner Join further divided into three subtypes: Theta join Natural join EQUI join Theta Join Theta Join allows you to merge two tables ba...

List vs Tuple

List vs Tuple (Image by - Sharma Guides | Subham232330) List | |- Syntax :- [2,3,4] | |- Mutable :- Elements can be changed after creation. | |- Length :- Variable length. | |- Memory :- List takes more memory than a tuple. Tuple | |- Syntax :- (2,3,4) | |- Immutable :- Elements cannot be changed after creation. | |- Length :- Fixed length. | |- Memory :- It takes less memory than a list.

Relational Algebra

Relational Algebra Relational algebra is a procedural query language. It gives a step-by-step process to obtain the result of the query. It uses operators to perform queries. Types of Relational Operation 1. Select Operation: The select operation selects tuples that satisfy a given predicate.  It is denoted by sigma (σ). Notation: σ p(r) Where: σ is used for selection prediction r is used for relation p is used as a propositional logic formula which may use connectors like: AND OR and NOT. These relational can use as relational operators like =, ≠, ≥, <, >, ≤. For example: LOAN Relation BRANCH_NAME LOAN_NO AMOUNT Downtown L-17 1000 Redwood L-23 2000 Perryride L-15 1500 Downtown L-14 1500 Mianus L-13 500 Roundhill L-11 900 Perryride L-16 1300 Input: σ BRANCH_NAME="perryride" (LOAN) Output: BRANCH_NAME LOAN_NO AMOUNT Perryride L-15 1500 Perryride L-16 1300 2. Project Operation: This operation shows the list of those attributes that we wish to appear in the result. Rest...