Posts

Showing posts from April, 2018

Can we override static method in java ?

No ! we cannot override the static methods. Since static method belongs to class level not object level. class StaticExe1 { public static void run() { System.out.println("run of StaticExe1"); } public  void fly() { System.out.println("fly of non-static Exe1"); } } class StaticExe2 extends StaticExe1 { public static void run() { System.out.println("run of StaticExe2"); } public  void fly() { System.out.println("fly of non-static Exe2"); } } class StaticExe3 extends StaticExe2 { public static void run() { System.out.println("run of StaticExe3"); } public  void fly() { System.out.println("fly of non-static Exe3"); } } public class StaticMethod { public static void main(String[] args) { StaticExe2 ex = new StaticExe3 (); ex.run(); ex.fly(); } }

Sort a Map by value !!

Sorting a Map by value in Java: import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; public class SortMapByValue { public static void main(String[] args) { Map<String, Integer> map = new HashMap<String, Integer>(); map.put("z", 2); map.put("q", 0); map.put("p", 5); map.put("s", 8); map.put("o", 0); map.put("r", 9); map.put("v", 8); System.out.println(map); Set<Entry<String, Integer>> entrySet = map.entrySet(); List<Entry<String, Integer>> lists = new ArrayList<Entry<String, Integer>>(entrySet); Collections.sort(lists, new Comparator<Entry<String, Integer>>() { @Override public int compare(Entry<String, Integer> o1, Entry<String, Integer> o...

Java single field sort using Comparator.

import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; class SortBySalary implements Comparator<Human> { @Override public int compare(Human o1, Human o2) { if (o1.salary > o2.salary) return 1; if (o1.salary < o2.salary) return -1; return 0; } } class Human { String name; int age; double salary; public Human(String n, int a, double s) { this.name = n; this.age = a; this.salary = s; } public Human() { } public String toString() { return this.name + " " + this.age + " " + this.salary; } } public class ComparatorExe { public static void main(String[] args) { List<Human> l = new ArrayList(); Human h1 = new Human("ritesh", 12, 6000); Human h2 = new Human("raju", 18, 5000); Human h3 = new Human("ishaan", 10, 7000); Human h4 = new Human("yuyu", 15, 333); Human h5 = new Hu...

Java multiple way sorting - Comparator example .

Compare multiple fields using Comparator: import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.List; class SortByAnimalByName implements Comparator<Animal> { @Override public int compare(Animal o1, Animal o2) { return o1.name.compareTo(o2.name); } } class SortByAnimalByColor implements Comparator<Animal> { @Override public int compare(Animal o1, Animal o2) { return o1.color.compareTo(o2.color); } } class SortByAnimalByWeight implements Comparator<Animal> { @Override public int compare(Animal o1, Animal o2) { if (o1.weight > o2.weight) { return 1; } if (o1.weight < o2.weight) { return -1; } return 0; } } class SortByAllAnimal implements Comparator<Animal> { List<Comparator<Animal>> com; SortByAllAnimal(Comparator<Animal>... all) { this.com = Arrays.asList(all); } @Override public...

What is the output of the program ?

class SampleExec1  { void run() { System.out.println("SampleExec1 run"); } } class SampleExec2 extends SampleExec1 { void run() { System.out.println("SampleExec2 run"); } } public class SampleExecution { public static void main(String[] args) { SampleExec2 ex = new SampleExec1(); ex.run(); } } Output : compile time error at line 15. Type mismatch: cannot convert from SampleExec1 to SampleExec2

Write a program to find maximum profit

public class MaxProfit {   public static void main(final String[] args) {     int a[] = { 4, 1, 10, 2, 3, 5, 6, 25, 48, 8, 26 };     int max = a[a.length - 1];     int min = a[a.length - 1];     int indexOfMax = a.length - 1;     int indexOfMin = a.length - 1;     int dif = -1;     for (int i = a.length - 2; i >= 0; i--) {       if (max < a[i]) {         max = a[i];         indexOfMax = i;       }       if (max > a[i]) {         min = a[i];         indexOfMin = i;       }       if ((indexOfMax > indexOfMin)) {         if (dif < (max - min)) {  ...

Write a program to count each unique words in a given string.

public class WordCountByMapAlgoritham { public static void main(String[] args) { String s = "this is java code. this java code is highly recommended for java developer !!"; String a[] = s.split(" "); Map<String, Integer> map = new HashMap<String, Integer>(); for (String word : a) { if (map.get(word) != null) { map.put(word, map.get(word) + 1); } else map.put(word, 1); } System.out.println(map); } } Output:  {!!=1, java=3, code=1, code.=1, this=2, for=1, is=2, developer=1, highly=1, recommended=1}

Write a program to check prime number.

Write a program to check prime number. public class PrimeNumberAlgorithm { public static void main(String[] args) { isPrimeNumber(11); } private static void isPrimeNumber(int n) { boolean flag = true; int m = n / 2; for (int i = 2; i <= m; i++) { if (n % i == 0) { flag = false; break; } } System.out.println(flag == true ? "Prime number !!" : "Not prime number !!"); } }

Today Walkins 12th April

Image
1. Ionidea Hiring for HR Executive | Direct Walkin Experience : 0-1 Yrs  Qualification: Only MBA Candidates Essential Skills: Very good attitude with enthusiasm and willingness to learn and contribute more. Excellent communication and interpersonal skills. Should have the intelligence and maturity to carry out varied tasks and responsibilities. Strong Time Management and Priority Management skills. Date: 12th to 13th April 2018 Timing : 11:00 AM - 1:00 PM  Venue: Ionidea Interactive Pvt Ltd 38-40 EPIP Zone , Whitefield - 66 Google Map:  https://goo.gl/maps/UduSMHYA4H52 ========================================== 2. Pole To Win Hiring for Software Testing, Game Testing, Customer Support | Direct Walkin Exp: Freshers / Experienced Skills: Excellent verbal and written communication skill Be good in logical, analytical and reasoning skill Possess strong gaming skills Well versed in Manual Testing concepts, Gaming Platforms and Basic Computers. Date: 12th April to 30th April...

Today Walkins 7th April 2018

Image
1. Sentienz Solutions (P) Ltd Hiring for Java Developer | Direct Walkin Exp: 0 to 6 yrs Criteri BE / BTech(CS,IS,IT,EEE), MCA 65% throughout career Java Developers (10 positions) Core Java Developers (10 nos) Experience 0-6 years Core Java with good experience in Datastrcutures and algorithms Experience in one or more of the following technologies : Cassandra, Elastic Search, Mongodb, Hbase, Couchdb, Kafka, Hadoop, Spark, Hive, Pig, Bigquery Application Developers (10 positions) Experience in Microservices, Spring Boot, JPA, SQL, J2e, Jenkins, Ansible, Rest API and with exposure to AWS or GCP Date: 7th April Time: 10:00AM Venue: 3rd Floor, PR Business Center, Kadubisanahalli, Marathahalli, Landmark: Above Croma Stores , Opposite JP Morgan, Bengaluru, Karnataka 560087 Google Map: https://goo.gl/maps/qGdJUdgREnv ========================================== 2. Wipro Hiring for Tech Support | Direct Walkin Exp: Freshers / Experienced #NOTE : BE / ...

Today Walkins 6th April 2018

Image
1. Ionidea Hiring for HR Executive | Direct Walkin Experience : 0-1 Yrs Qualification: Only MBA Candidates Essential Skills: Very good attitude with enthusiasm and willingness to learn and contribute more. Excellent communication and interpersonal skills. Should have the intelligence and maturity to carry out varied tasks and responsibilities. Strong Time Management and Priority Management skills. Date: 6th April 2018 Timing : 11:00 AM - 1:00 PM Venue: Ionidea Interactive Pvt Ltd 38-40 EPIP Zone , Whitefield - 66 Google Map: https://goo.gl/maps/UduSMHYA4H52 ========================================== 2. Pole To Win Hiring for Software Testing, Game Testing, Customer Support | Direct Walkin Exp: Freshers / Experienced Skills: Excellent verbal and written communication skill Be good in logical, analytical and reasoning skill Possess strong gaming skills Well versed in Manual Testing concepts, Gaming Platforms and Basic Computers. Date: 6th April to 30...

Today Walkins 5th April 2018

Image
1. Ionidea Hiring for HR Executive | Direct Walkin Experience : 0-1 Yrs Qualification: Only MBA Candidates Essential Skills: Very good attitude with enthusiasm and willingness to learn and contribute more. Excellent communication and interpersonal skills. Should have the intelligence and maturity to carry out varied tasks and responsibilities. Strong Time Management and Priority Management skills. Date: 5th, 6th April 2018 Timing : 11:00 AM - 1:00 PM Venue: Ionidea Interactive Pvt Ltd 38-40 EPIP Zone , Whitefield - 66 Google Map: https://goo.gl/maps/UduSMHYA4H52 ========================================== 2. Pole To Win Hiring for Software Testing, Game Testing, Customer Support | Direct Walkin Exp: Freshers / Experienced Skills: Excellent verbal and written communication skill Be good in logical, analytical and reasoning skill Possess strong gaming skills Well versed in Manual Testing concepts, Gaming Platforms and Basic Computers. Date: 5th April ...

Today Walkins 4th April 2018

Image
Pole To Win Hiring for Software Testing, Game Testing, Customer Support | Direct Walkin Exp: Freshers / Experienced Skills: Excellent verbal and written communication skill Be good in logical, analytical and reasoning skill Possess strong gaming skills Well versed in Manual Testing concepts, Gaming Platforms and Basic Computers. Date: 4th April to 30th April 2018 (Monday To Saturday) Time: 10:00AM to 1:00PM Venue: Pole to win international, fortune summit, 4th floor, Roopena Agrahara, Hosur Road, Bangalore, 560068 */7\ ========================================== Time Analytic & Shared Services Pvt. Ltd. Hiring for Associate Analyst | Direct Walkin **MBA Candidates Must Attend** Job Requirement: Fresher or under 1year of Work Ex either in Analytics, Retail Preferably an MBA from a reputed college Good grades in their Under Grads and Grads. Good Communication skills Excellent in Excel Basics Macros is not important. Strong Analytical and Log...