EduLearn - Online Education Platform

Welcome to EduLearn!

Start learning today with our wide range of courses taught by industry experts. Gain new skills, advance your career, or explore new interests.

Browse Courses

Java practice questions

Grocery store discount system scenario A Grocery store provides discount based on the total bill amount   Above Rs.1000: 20% discount   Rs.500 to Rs.1000: 10% discount   Below Rs.500: No discount   Write a java program that calculates the final bill amount after applying the discount   import java.util.*;   class ASC { public […]

Java practice programs

A company has installed a smart elevator system in its office building. The elevator operates based on the following rule. The elevator can move between 1st to 10th floor Users can enter their desired floor,but if the floor is outside the range,the system should print “Invalid floor” The elevator starts from 1st floor and moves […]

Java common elements in array

Find the common elements in 2 list(arraylist)   import java.util.*;   class ASC { public static void main(String args[]) {   ArrayList<Integer> a=new ArrayList<>(); a.add(1); a.add(2); a.add(3);// 1 2 3   ArrayList<Integer> b=new ArrayList<>(); b.add(4); b.add(2); b.add(5);//4 2 5   a.retainAll(b);//retainall will keep only the common values   System.out.println(a);}}

Java Collection framework in arrays

class ASC { public static void main(String args[]) { ArrayList<Integer> find=new ArrayList<Integer>();1 8 9 2 6 6   Scanner s=new Scanner(System.in);   for(int i=0;i<5;i++) { int temp=s.nextInt();//temp=8 if(!find.contains(temp))//true find.add(temp);//[1 8 9 2 6] } Collections.sort(find);[1 2 6 8 9] System.out.println(find); }}

Java Array list by adding elements

Question: Create an Arraylist by adding elements Apple,banana,mango   First element:Apple Second element:banana Third element:mango   sort the list reverse the list ——————————- import java.util.*;   class ASC { public static void main(String args[]) { ArrayList<String> fruits=new ArrayList<String>();   fruits.add(“Apple”); fruits.add(“Banana”); fruits.add(“Mango”);   System.out.println(“First element:”+fruits.get(0)); System.out.println(“second element:”+fruits.get(1)); System.out.println(“Third element:”+fruits.get(2));   Collections.sort(fruits); System.out.println(“Sorted list:”+fruits);   Collections.reverse(fruits); […]

Java collection frameworks in arrays

  Arrays in java import java.util.*; class ASC { public static void main(String args[]) { ArrayList<String> slist=new ArrayList<String>(); slist.add(“honey”);//0 slist.add(“joes”);//1 System.out.println(slist.indexOf(“joes”)); ArrayList<String> slist2=new ArrayList<String>(); slist2.addAll(slist); System.out.println(slist); System.out.println(slist2); }}

What is Collection framework in java

Collection framework:   A Java collection framework provides an architecture to store and manipulate a group of elements or objects   –>It “Provides an architecture” – means it gives a well-structured set of classes and interfaces.   –>”To store, retrieve, and manipulate” – covers the basic operations like adding, removing, searching, sorting, etc.   –>”Group […]

Java program for printing an element

      Here’s a simple Java program that takes a sentence as input and prints the number of letters in each word: ✅ Java Program: Count Letters in Each Word import java.util.Scanner;   public class WordLengthCounter { public static void main(String[] args) { Scanner scanner = new Scanner(System.in);   // Input sentence System.out.print(“Enter a […]

Java practice programs

The function accepts two positive integers ‘r’ and ‘unit’ and a positive integer array ‘arr’ of size ‘n’ as its argument,’r’ represents the number of rats present in an area,’unit’ is the amount of food each rat consumes and each ith elements of an array ‘arr’ represents the amount of food present in ‘i+1’ house […]

Solid principles in java language

)Open/Closed Principle(OCP) Software entities should be open for extension but closed for modification. This allows adding new function without altering existing code.     class AreaCalculator { public double calculateArea(String shape,double radius,double length,double breadth) { if(shape.equals(“circle”)) { return Math.PI*radius*radius; } else if(shape.equals(“rectangle”)) { return length*breadth; } } class OCPviolation { public static void main(String args[]) […]

EduLearn - Online Education Platform

Welcome to EduLearn!

Start learning today with our wide range of courses taught by industry experts. Gain new skills, advance your career, or explore new interests.

Browse Courses

Popular Courses

[Course Image]

Introduction to Programming

Learn the fundamentals of programming with Python in this beginner-friendly course.

12 Hours Beginner
[Course Image]

Data Science Essentials

Master the basics of data analysis, visualization, and machine learning.

20 Hours Intermediate
[Course Image]

Web Development Bootcamp

Build modern websites with HTML, CSS, JavaScript and popular frameworks.

30 Hours Beginner
[Course Image]

Digital Marketing Fundamentals

Learn SEO, social media marketing, email campaigns and analytics.

15 Hours Beginner
Educational Website Footer