Posts

Showing posts with the label java

Checking Character only in String - Java 2024 - MNC - Technical Interview

 Checking if the String contains Character only     Get the input from the user using Scanner class. Then create a method to check the following condition. 1. Check if the string is null or empty, if it is directly return false. 2. Iterate the String using for loop inside the for loop, use the if for condition checking. 3. Condition is check the Character only, for this use the Character Wrapper class, in that we have  isAlphabetic() method to check the character. 4. This method will return true or false based on it is character or not. Code: package com.dinatechy.challange; import java.util.Scanner; public class CheckCharacter { public static void main(String[] args ) { //Check the String only contains Character or Not Scanner scan = new Scanner(System. in ); System. out .print( "Enter the String : " ); String data = scan .next(); scan .close(); boolean isChar = checkOnlyCharacter ( data ); System. out .println( isChar ? "Yes...

Java Program Question - MNC - Technical Interview

                Here we are going to see a very Interesting and Complicated Java Programming Questions, which is asking in literally all MNC's Technical Interview's Input : Array -- { 5,1,8,-5,-1,6,2,-2,45,-55,-9,-89,9 } Output :  Array -- { -89 -55 -9 9 -5 5 -2 2 -1 1 6 8 45 } Program :  package com.array; public class SortingArray { public static void main ( String [] args ) { int [] arr = { 5 , 1 , 8 ,- 5 ,- 1 , 6 , 2 ,- 2 , 45 ,- 55 ,- 9 ,- 89 , 9 }; for ( int a : arr ) { System . out . print ( a + " " ); } System . out . println (); for ( int i = 0 ; i < arr . length ; i ++) { for ( int j = i ; j < arr . length ; j ++) { if ( arr [ i ]> arr [ j ]) { int temp = arr [ i ]; arr [ i ] = arr [ j ]; arr [ j ] = temp ; } } } for ( int i = 0 ; i < arr . length ; i ++) {            ...

Control Statement in Java - Flow Chart - Professional Programming

Control Statement :                 If we want to control our program based on some condition, their is the place we must know the concept of Control Statement.               Naturally all the Control Statement executes based on true or false .              Their are various types of control statements,  Types : Decision Making Statement Iteration or Looping statements Jump Statement Decis ion Making Statement :                Decision making statements in Java refer to those statements that allow the programmer to specify decisions or conditional execution flows in their code. The decision making statements in Java are primarily composed are .                Types :  if if-else else-if nested if-else switch     if Statement :        ...