A recursive function solves a particular problem by calling a copy of itself and solving smaller sub problems of the original problems. Many more recursive calls … 1): Terminates when the base case becomes tr… 3): Every recursive call needs extra space in the … 2): Used with functions 4): Smaller code size Rules of Recursion:-Continue reading “Recursion”
Tag Archives: java
Artificial
What is Artificial Intelligence? Artificial intelligence (AI) is a wide-ranging branch of computer science concerned with building smart machines capable of performing tasks that typically require human intelligence. AI Approaches and Concepts Less than a decade after breaking the Nazi encryption machine Enigma and helping the Allied Forces win World War II, mathematician Alan Turing changedContinue reading “Artificial”
Scanner
The Scanner class is used to get user input, and it is found in the java.util package. To use the Scanner class, create an object of the class and use any of the available methods found in the Scanner class documentation. Program:- Output Screenshot:-
Swapping Four numbers without have a temporary variable
Program:- Output Screenshot:-
Swapping three numbers without have a temporary variable
Program:- Output Screenshot:-
Pattern Program
Pattern programs are nothing but patterns consisting of numbers, alphabets or symbols in a particular form. These kinds of pattern programs can be solved easily using for loop condition. Program 1:- Output Screenshot:- Program 2:- Output Screenshot:- Program 3:- Output Screenshot:- Program 4:- Output Screenshot:- Program 5:- Output Screenshot:-
Find the Divisor of Number
Program:- Output Screenshot:-
For loop
A “For” Loop is used to repeat a specific block of code a known number of times. For example, if we want to check the grade of every student in the class, we loop from 1 to that number. When the number of times is not known before hand, we use a “While” loop. InitiateContinue reading “For loop”
Assignment – 6
GOAL: Understanding Multilevel Inheritance, Abstraction Create an abstract class called HeadOffice. Have below normal methods in it. 2.1. public void check_accounts(int amount) – Have a print statement inside here 2.2. public int pay_tax(int amount) – return this.amount from here Have an abstract method as below. 3.1. public abstract void receive_Customers() Create another abstract class calledContinue reading “Assignment – 6”
Simple Java program
class First{public static void main(String[] args){System.out.println(“Hello java”);}} Class name – First (First letter must be a Capital) public static void main(String[] args) – Main method of a program System.out.println(“Hello java”); – Output Statement Output:- Hello java Java Program to Add two Numbers public class AddTwoNumbers { public static void main(String[] args) { int num1 =Continue reading “Simple Java program”