Posts

Showing posts with the label Java

Java File Handling

 1. This program helps to create a new file , with their inner content:  package com.test.file ; import java.io.FileOutputStream ; import java.io.IOException ; import java.nio.charset.StandardCharsets ; import java.util.Scanner ; public class CreateNewFIleWithContent { public static void getFileCreated (){ Scanner sc = new Scanner ( System . in ); System . out . print ( " Enter the file name path : " ); String filePath = sc . nextLine (); filePath = filePath . replace ( "/" , " \\ " ); try { FileOutputStream fos = new FileOutputStream ( filePath , true ); System . out . print ( " Enter the content inside the file: " ); String content = sc . nextLine (); fos . write ( content . getBytes ()); fos . close (); } catch ( IOException e ){ e . printStackTrace (); } } public static void main ( String [] args ) {...

Java Selenium Programs & Concepts:

 Refer to this page to have good diving into basics and advanced logical programs used in automating various web pages.  The index are: 1. Using ChromeOptions: To make in use chrome to config download desired folder. 1. Using ChromeOptions: To make in use chrome to config download desired folder.  (This will also not show the Deprecated message as we know that DesiredCapabilities now not in use) String fileNewPath = " C:/User/Documents/Test ";  String filePath = fileNewPath.replace('/', '\\'); Map<String, Object> chromePrefs = new HashMap<String, Object>(); chromePrefs .put(" profile.default_content_settings.popups", 0 ); chromePrefs .put("download.default_directory", filePath ); chromePrefs .put(" download.prompt_for_download ", false ); chromePrefs .put("plugins.plugins_disabled", "Chrome PDF Viewer"); ChromeDriverService service =               new ChromeDriverService.Builder().usingDriverExec...

Solve: No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

 If you face this issue on eclipse while running your script mainly it some when we run our scripts using Maven Commands: if JRE is configured instead of JDK and jdk is not available by default on Exclipse Java Complier Config. Then go to  JAVA BUILD PATH  > Add Library... > JRE LIBRARY SYSTEM > Explicitly add JDK path from local computer and remove JRE and JRE conf to JDK

How to start / create a fresh JAVA Project into Eclipse IDE:

Image
  How to start / create a fresh JAVA Project into Eclipse IDE:  Click on Create New Java Project on Eclipse IDE: Enter Project Name CLick Next: you can find Java Src Tree structure Click FINISH Do right click on Java New Project -> Create a class Create a Java file : src-newProject- reverseString.java  (camelCase) Click Finish, you will find the Java class page: To enter the program

Java Basics Interview Perspective

Image
Basic concepts: 1. Interface 2. Java String Concepts  3. Difference between StringBuffer & StringBuilder 4. Immutable Concept -------------------------------------------------------------------------------  1. Interface : The Interface = 100% ABSTRACTION method Methods are : public & abstract (BY DEFAULT) Variable : public , static & final (BY DEFAULT) And class implements multiple INTERFACE and MUST NEED TO define (implement) methods inside the class otherwise we get " COMPILE TIME ERROR "  2. SUPER Keyword (Super() ) The use of the SUPER keyword is to invoke the constructor of the parent class.  So as in the down example, the Object created for the SubClass itself will FIRST  invoke parent class NO ARG CONSTRUCTOR " SuperConst() " and then Child Constructor. public class SuperConst { SuperConst(){ System.out.println("The parent class constructor with No Args"); } SuperConst(String str){ System.out.println("The parent cl...

Java Program which Required for Testing Engineer

Image
----------JAVA Program starts here:------------- WAP to reverse a String without using inbuilt function. WAP  to reverse a String using inbuilt function. WAP to reverse words at ODD place in a sentence. WAP to check prime number (1-100) WAP to check the ARMSTRONG number. WAP to check the Fibonacci Series. A. WAP to print using DUPLICATES using HashMap   &   Duplicates Word (Using ForEach loop) WAP to do sorting of ARRAY USING for loop   &  Descending order The only Odd & Only Even WAP for GETTER & SETTER method. WAP to generate pattern. Pattern Problem- Star at ODD place  Pattern Problem- Triangle Pattern Problem- Reverse Triangle Pattern Problem - Pyramid WAP to prog to swap to Strings w/o using third variable. Singleton class example using getInstance() Program to return Min & Max Value from the Array  ------------------------------------------------------------------------------------------------ 1. WAP to reverse ...