B2 Tech

Web Dev Snippets

  • Facebook
  • Twitter
  • Google Plus
  • Home
  • Java
    • Core Java
    • Core Java Programs
    • Java Swings
    • JavaFX
  • Web Technologies
    • Angular 10
    • Angular 2
    • Angular 9
    • Boostrap 4
    • CSS
    • Express.js
    • High Charts
    • HTML
    • Javascript
    • Javascript Programs
    • jQuery
    • Mongoose
    • Nodejs
    • Typescript
  • Full Stack Applications
    • CRUD Applications
  • Advance Java/J2EE
    • JSP
    • Servlets
    • JSF
    • Thymeleaf
    • Spring MVC
    • Spring Boot
    • Spring Security
    • JPA
    • Hibernate
    • Struts
    • MyBatis/iBatis
  • Interview Programs
  • Web Services
    • REST Services
    • SOAP Services
  • Testing
  • About
  • Contact

Category - Java

  • Core Java
  • Java Swings

Java Swing display JFrame window at center of the screen

3 weeks ago
by Bushan Sirgur
1 min read
Add Comment

Hey guys in this post, we will discuss how to place the JFrame window at the center of the screen. Read: Create Basic JFrame window and display it on the Screen When we create the JFrame window, by default it is not centered. It...

Continue reading

  • Core Java
  • Java Swings

Java Swing display Basic Window example

3 weeks ago
by Bushan Sirgur
1 min read
Add Comment

Hey guys in this post, we will discuss how to display the basic window using Java Swing. Example import javax.swing.JFrame; public class BasicWindow extends JFrame{ public static void main(String[] args) { UserInput...

Continue reading

  • Core Java

Java 8 Stream API collect() method Example

3 weeks ago
by Bushan Sirgur
6 min read
Add Comment

Hey guys, in this post we will discuss the Java 8 Stream API collect() method, we will also look at some of the examples. Overview Java stream collect() method is used to perform mutable fold operations means repackaging...

Continue reading

  • Core Java

Example to read the user input using Scanner Class

3 weeks ago
by Bushan Sirgur
3 min read
Add Comment

Hey guys in this, we will discuss accepting the user input in Java with Scanner class. If we are creating a console-based application, it’s essential that takes the user input and produces the correct output. So in this...

Continue reading

  • Core Java

5 Different Ways to Create Object in Java

3 weeks ago
by Bushan Sirgur
2 min read
Add Comment

Hey guys in this post, we will see the 5 different ways of creating objects in java. Let’s discuss it one by one – 5 Different ways Following are the different ways to create a java object. Using new keyword This...

Continue reading

  • Core Java Programs
  • Interview Programs
  • Javascript Programs

Given an array of ints, return true if the value 3 appears in the array exactly 3 times, and no 3’s are next to each other.

4 weeks ago
by Bushan Sirgur
1 min read
Add Comment

Following are the test cases Test cases Result Status haveThree({12,3,4,3,88,3}) true OK haveThree({22,3,3,3,17,3}) false OK haveThree({3,4,3,6,3,7}) true OK Java solution package test; public class Program20...

Continue reading

  • Core Java Programs
  • Interview Programs
  • Javascript Programs

Given an array of ints, return true if the sum of all the 2’s in the array is exactly 8.

4 weeks ago
by Bushan Sirgur
1 min read
Add Comment

Following are the test cases Test cases Result Status sum28({10,20,30,40,50,60,2}) false OK sum28({2,10,7,2,2,2}) true OK sum28({5,6,1,2,2,2}) false OK Java solution package test; public class Program19 { public...

Continue reading

  • Core Java Programs
  • Interview Programs
  • Javascript Programs

Given a string and an int n, return a string made of the first and last ‘ n’ chars from the string. The string length will be at least n.

4 weeks ago
by Bushan Sirgur
1 min read
Add Comment

Following are the test cases Test cases Result Status nTwice(Hello,2) Helo OK nTwice(Chocolate,3) Choate OK nTwice(java,1) ja OK Java solution package test; public class Program18 { public static void...

Continue reading

  • Core Java Programs
  • Interview Programs
  • Javascript Programs

Given an “out” string length 4, such as “<<>>”, and a word, return a new string where the word is in the middle of the out string, e.g. “<>”

4 weeks ago
by Bushan Sirgur
1 min read
Add Comment

Following are the test cases Test cases Result Status makeOutWord(<<>>,Yay) <<Yay>> OK makeOutWord([[]],Word) [[Word]] OK makeOutWord([((JAVA))] ((JAVA)) OK Java solution package...

Continue reading

  • Core Java Programs
  • Interview Programs
  • Javascript Programs

Return true if the given string contains 1 or 3 ‘e’ chars. Otherwise return false.

4 weeks ago
by Bushan Sirgur
1 min read
Add Comment

Following are the test cases Test cases Result Status stringE(Hello) true OK stringE(Heelele) false OK stringE(Heelle) true OK Java solution package test; public class Program16 { public static void...

Continue reading

  • Core Java Programs
  • Interview Programs
  • Javascript Programs

Return true if the array contains, somewhere, three increasing adjacent numbers like …. 4, 5, 6, … or 23, 24, 25.

4 weeks ago
by Bushan Sirgur
1 min read
Add Comment

Following are the test cases Test cases Result Status tripleUp({1,2,3,7,5,9}) true OK tripleUp({1,4,5,6,2}) true OK tripleUp({1,2,4,5}) false OK Java solution package test; public class Program15 { public static...

Continue reading

  • Core Java Programs
  • Interview Programs
  • Javascript Programs

Pass an int as parameter. Find the sum of the digits in the number and return it.

4 weeks ago
by Bushan Sirgur
1 min read
Add Comment

Following are the test cases Test cases Result Status sumOfDigits(144) 9 OK sumOfDigits(457) 16 OK sumOfDigits(345) 12 OK Java solution package test; public class Program14 { public static void main(String[]...

Continue reading

  • Core Java Programs
  • Interview Programs
  • Javascript Programs

Given a string of even length, return the first half. So the string “WooHoo” yields “Woo”.

4 weeks ago
by Bushan Sirgur
1 min read
Add Comment

Following are the test cases Test cases Result Status firstHalf(HelloThere) Hello OK firstHalf(abcdef) abc OK firstHalf(Word) Wo OK Java solution package test; public class Program13 { public static void...

Continue reading

  • Core Java Programs
  • Interview Programs
  • Javascript Programs

Given an array of ints, return true if one of the first 4 elements in the array is a 9. The array length will be greater than 4.

4 weeks ago
by Bushan Sirgur
1 min read
Add Comment

Following are the test cases Test cases Result Status arrayFront9({1,2,9,3,4}) true OK arrayFront9({9,2,3,4,56}) true OK arrayFront9({2,3,4,5}) false OK Java solution package test; public class Program12...

Continue reading

  • Core Java Programs
  • Interview Programs
  • Javascript Programs

Write a program to generate Fibonacci series of limit number of elements.

4 weeks ago
by Bushan Sirgur
1 min read
Add Comment

Following are the test cases Test cases Result Status generateFibSeries(5) {0,1,1,2,3} Ok generateFibSeries(7) {0,1,1,2,3,5,8} Ok generateFibSeries(10) {0,1,1,2,3,5,8,13,21,34} Ok Java solution public class Program11...

Continue reading

  • Core Java

Java 8 Stream reduce() Example

4 weeks ago
by Bushan Sirgur
2 min read
Add Comment

Hey guys in this post we will discuss about reduce() of Stream API which is introduced in Java 8. Introduction Many times we need to perform operations where a stream reduces to single resultant value, for example, maximum...

Continue reading

  • Core Java

Java 8 Stream map() Example

4 weeks ago
by Bushan Sirgur
2 min read
Add Comment

Hey guys in this post, we will discuss everything about map() in Streams which is introduced in Java 8. Introduction map() function returns a stream consisting of the results of applying the given function to the element of...

Continue reading

  • Core Java

Most commonly used java string methods

1 month ago
by Bushan Sirgur
5 min read
Add Comment

Hey, guys in this post will discuss the most commonly used java string methods. The string is the most commonly used class while building any java application, this is why the java team has provided several built-in String...

Continue reading

  • Core Java

Java 8 Stream API sorted() Example

1 month ago
by Bushan Sirgur
4 min read
Add Comment

Hey guys in this post let’s discuss aboutsorted()introduced in Java 8 java.util.stream.Steam interface. On the streams() we can perform some aggregate operations such as filter(), sorted() and map(). In this post...

Continue reading

  • Core Java

Java 8 Stream API filter() example

1 month ago
by Bushan Sirgur
3 min read
Add Comment

Hey guys in this post let’s discuss about filter() introduced in Java 8 java.util.stream.Steam interface. On the streams() we can perform some aggregate operations such as filter(), sorted() and map(). In this post...

Continue reading

  • Core Java Programs
  • Interview Programs
  • Javascript Programs

Given a string, return a new string where the first and last chars have been exchanged

2 months ago
by Bushan Sirgur
1 min read
1 Comment

Test cases Test cases Expected Result frontBack(abcd) dbca OK frontBack(Bee) eeB OK frontBack(MazE) EazM OK Java solution: public class Program10 { public static void main(String[] args)...

Continue reading

  • Core Java Programs
  • Interview Programs
  • Javascript Programs

Pass an int array and an int and do a search of the second parameter in the first, and return true/false.

2 months ago
by Bushan Sirgur
1 min read
Add Comment

Test cases Test cases Expected Result searchElement({33,44,21,98,27,94},21) true OK searchElement({1232,432,546,980,984},980) true OK searchElement({3,4,9,87,29},2) false OK Java solution: public class Program9...

Continue reading

  • Core Java Programs
  • Interview Programs
  • Javascript Programs

Given an array of ‘N’ elements .Return the sum of all array elements

2 months ago
by Bushan Sirgur
1 min read
Add Comment

Test cases Test cases Expected Result arraySum({5,5,5,5,5}) 25 OK arraySum({1,3,4,7,8}) 23 OK arraySum({100,200,300}) 600 OK Java solution: public class Program8 { public static void main(String[] args) { int a[]...

Continue reading

  • Core Java Programs
  • Interview Programs
  • Javascript Programs

Accept a string as parameter. Find out how many consonants present in it.

2 months ago
by Bushan Sirgur
1 min read
Add Comment

Test cases: Test cases Expected Result countConsonents(instanceof is for references only) –>[18] 18 OK countConsonents(Object Oriented) –>[8] 8 OK countConsonents(Design Patterns88)...

Continue reading

  • Core Java Programs
  • Interview Programs
  • Javascript Programs

Pass a string as parameter. Find out how many vowels present in it

2 months ago
by Bushan Sirgur
1 min read
Add Comment

Test cases: Test cases Expected Result countVowels(instanceif is for references only) 11 OK countVowels(Object Oriented) 6 OK countVowels(Design Patterns) 4 OK Java solution: public class Program6 { public static...

Continue reading

  • Core Java Programs
  • Interview Programs
  • Javascript Programs

Given two strings, append them together (known as “concatenation”) and return the result.

2 months ago
by Bushan Sirgur
1 min read
Add Comment

Test cases: Test cases Expected Result stringConcat(Hello,World) Hello World OK stringConcat(Code,ranch) Code ranch OK stringConcat(Web,Application) Web Application OK Java solution: public class Program5 { public...

Continue reading

  • Core Java Programs
  • Interview Programs
  • Javascript Programs

Return true if the given non-negative number is a multiple of 3 or a multiple of 5

2 months ago
by Bushan Sirgur
1 min read
Add Comment

Test cases: Test cases Expected Result or35(15) true OK or35(8) false OK or35(12) true OK Java solution: public class Program4 { public static void main(String[] args)...

Continue reading

  • Core Java Programs
  • Interview Programs
  • Javascript Programs

Test whether the number is divisible by 7 or not

2 months ago
by Bushan Sirgur
1 min read
Add Comment

Test cases: Test cases Expected Result isDivisibleBy7(17) false OK isDivisibleBy7(77) true OK isDivisibleBy7(12) false OK Java solution: public class Program3 { public static void main(String[] args)...

Continue reading

  • Core Java Programs
  • Interview Programs
  • Javascript Programs

Check the given number is odd or even

2 months ago
by Bushan Sirgur
1 min read
Add Comment

Test cases: Test cases Expected Result testOddEven(12) even OK testOddEven(3) odd OK testOddEven(-55) odd OK Java solution: package test; public class Program2 { public static void main(String[] args)...

Continue reading

  • Core Java Programs
  • Interview Programs
  • Javascript Programs

Pass two ints as parameter and return the sum of numbers.

2 months ago
by Bushan Sirgur
1 min read
Add Comment

Test cases: Test cases Expected Result sum(10,12) 22 OK sum(1,2) 3 OK sum(2147483647,1) 2147483648 OK Java solution: public class Sum { public static void main(String[] args) { Sum.sum(10, 12); Sum.sum(1...

Continue reading

1 2 Next

About Author

View all posts

Support me


Love my tutorials? Please support me by donating:

Newsletter



Recent Posts

  • Spring Boot REST API Testing using JUnit 2 months ago
  • Spring boot @Bean annotation with example 2 months ago
  • Spring boot @Autowire annotation with example 2 months ago
  • Top 20 commonly used Javascript array methods with examples 2 months ago
  • Spring boot @RequestMapping annotation with example 2 months ago
  • Spring Boot, PostgreSQL, JPA, Hibernate RESTful CRUD API Example 2 months ago
  • Spring boot @ResponseBody annotation with example 2 months ago
  • Spring boot @RequestBody annotation example 2 months ago
  • HTML Basic Tags Explained with Examples 2 months ago
  • Spring boot @RequestParam annotation Example 2 months ago

Featured Posts

  • Spring Boot REST API Testing using JUnit
  • Spring boot @Bean annotation with example
  • Spring boot @Autowire annotation with example
  • Top 20 commonly used Javascript array methods with examples
  • Spring boot @RequestMapping annotation with example

Most Viewed Posts

  • Angular 2 and Spring REST Simple CRUD Application (16,464)
  • Login Form in JavaFX with MySQL Database (15,626)
  • A Complete CRUD Application with Spring MVC and MyBatis/iBatis (14,005)
  • Calculate AGE based on Date of birth using jQuery Calendar (11,159)
  • Complete CRUD Application in Spring MVC and Hibernate [XML Configuration] (10,819)

Categories

  • Angular 10 (2)
  • Angular 2 (2)
  • Angular 9 (7)
  • Boostrap 4 (9)
  • Core Java (13)
  • Core Java Programs (33)
  • CRUD Applications (33)
  • CSS (12)
  • Express.js (7)
  • Hibernate (12)
  • High Charts (3)
  • HTML (13)
  • Interview Programs (33)
  • Java Swings (4)
  • JavaFX (2)
  • Javascript (11)
  • Javascript Programs (20)
  • JPA (21)
  • jQuery (7)
  • JSP (16)
  • Mongoose (7)
  • MyBatis/iBatis (2)
  • Nodejs (7)
  • REST Services (30)
  • Servlets (2)
  • SOAP Services (1)
  • Spring Boot (40)
  • Spring MVC (21)
  • Testing (1)
  • Uncategorized (2)
Copyright © 2021. Created by Bushan Sirgur. Powered by B2 Tech.
  • Facebook
  • Linkedin
  • Instagram
  • Youtube
  • Github
  • Home
  • Java
    • Core Java
    • Core Java Programs
    • Java Swings
    • JavaFX
  • Web Technologies
    • Angular 10
    • Angular 2
    • Angular 9
    • Boostrap 4
    • CSS
    • Express.js
    • High Charts
    • HTML
    • Javascript
    • Javascript Programs
    • jQuery
    • Mongoose
    • Nodejs
    • Typescript
  • Full Stack Applications
    • CRUD Applications
  • Advance Java/J2EE
    • JSP
    • Servlets
    • JSF
    • Thymeleaf
    • Spring MVC
    • Spring Boot
    • Spring Security
    • JPA
    • Hibernate
    • Struts
    • MyBatis/iBatis
  • Interview Programs
  • Web Services
    • REST Services
    • SOAP Services
  • Testing
  • About
  • Contact
  • Facebook
  • Twitter
  • Google Plus