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);}}

Remove duplicates in arrays of java

Remove duplicates from an array using hashset   {1, 2, 2, 3, 4, 4, 5}   import java.util.*;   class ASC { public static void main(String args[]) { int arr[]={1, 2, 2, 3, 4, 4, 5};   HashSet<Integer> s=new HashSet<>();   for(int a:arr)//a=5 { s.add(a);//s=1 2 3 4 5 } System.out.println(s);   } }

Display elements by hashset in java

Add and display the elements(4 elements) using HashSet, check if an element exists there in a hashset,remove the element..   Find the smallest and largest element(number) using treeset   class Display { public static void main(String args[]) { HashSet<String> a=new HashSet<String>();   a.add(“apple”); a.add(“mango”); a.add(“banana”); a.add(“apple”); //apple mango banana   System.out.println(“mango is there..”+a.contains(“mango”));   a.remove(“mango”); […]

Sets and it’s types in java

Set: A set is a collection that does not allow duplicate elements part of java collection framework and inside util package used when you want to store the unique elements   Main features: No duplicates,can be looped using iterator or for-each loop HashSet–>Fast,unordered,no dulicates LinkedHashSet–>Maintains the insertion order TreeSet–Ascending order by default(sorted set)

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); […]

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