Posts

Showing posts from March, 2022

Java Exceptions Question Answers

Image
Java Exceptions - Question & Answers for Beginners     Goto Lesson   Some useful bits on java Exception to revise your subject that you learned in the class lesson. If not yet, please click the above top right link to go to lesson.   What is Exception ? Exception is nothing but a runtime error. Handling exception is called as Exception Handling.   How many types of errors in programming. 1.    Syntactical errors (Grammatical errors) occurs at compile time. 2.    Semantic errors  (Logical errors) occurs at runtime.     What is the mechanism for handling exceptions in Java? --Exception handling in Java is achieved through try, catch, and finally blocks.   What is the parent class of Exception. --Throwable In java, All classes are by default extended by which class. -- Object How many types of keyword java uses to handle exceptions, What are they? Java provided 5 keywords  to handle exceptions. 1.    try  2.    catch  3.    finally 4.    throw 5.    throws Divide by zero throws whic

JavaBasics Practice Question and Answers

Image
  Java Practice Question and Answers        Java Variables and Data types Find the Answers for the following Questions What is Literal? In Java. What data you have always written in double quotes (""). Class name should start with _______. Why to use variables. What  datatype you used to store text data in java. To store integers, what datatype you use? What is the use of ++. What is the default method in java ?give the name. Difference between char and String? How to convert one data type to another in Java? How to store character data in a variable in java, give an example? How to declare float value, give an example? How many types of scopes available for variables? What are Escape sequence characters, give 2 examples. What symbols you can use in a variable name. What is the maximum length of the variable name. How do you comment multiple lines in Java?   Java Methods What is method? Where it is created. Types of methods in java How many types of user defined methods W

Java Arrays Class-Tutorial

Image
Java Arrays Class Tutorial   Arrays class available in Java Collection Framework. This class belongs to java.util package. Arrays class provides various methods such as sort(), asList(), binarySearch(), equals(), copyOf(), fill() etc., to work with arrays. These methods are helpful  to manipulate the arrays efficiently. All the methods of arrays class static methods and can be called directly with the class name without creating an object.ex: Arrays.<function Name>   Table of contents Sort Arrays -  sort(), Convert Array to List    -  asList(arr) Search in Arrays - binarySearch() Compare two Arrays - equals() Create Copy of Arrays - copyOf(), Fill Array with Specific Value - fill()     Example: Sort Arrays   Syntax : Arrays. sort (arrayname);       import java.util.Arrays ; public class Arraysdemo { public static void main (String[] args) { String array[]={ "India" , "Australia" , "US" , "Japan" , "France" };

Java Scanner Class Tutorial

Image
Scanner Class  in Java   In this tutorial, we are going to learn about Scanner class in Java.  It allows us to read data from various sources such as using keyboard, file, string. This tutorial explains  you,  how to read data from various sources using scanner class. There are different methods available to read different types of data. You will find a list of methods provided in Scanner class  and how to use them.       Table of Contents   Reading Data from Keyboard - System.in   Reading Data from File   Reading Data from  String     Reading String Delimiter     1.    Reading Data from Keyboard - System.in import java.util.Scanner ; // import the Scanner class class Main { public static void main (String[] args) { Scanner input= new Scanner(System. in ); // String Input System. out . println ( "Enter Name" ); String name = input. nextLine (); // Numerical Input System. out . println ( "Enter Age" ); int age = inp

Convert Html to Pdf using PHP

Image
Convert Html to Pdf using PHP and DOMPDF      In this tutorial, you are going to learn, how to generate a PDF of HTML table contents using dompdf library in PHP on a Button Click. There are 3 files used in this tutorial. config.php   index.php generatepdf.php  Versions:  PHP Version 7.2.8  dompdf_0-8-3 Create a project folder and copy all the given files into the folder. Download the given dompdf library with above link. Extract and copy the dompdf folder, into a project folder.  Now your project folder looks as given in the picture.                   Next, Create a database, table with given  Queries. Db Queries: Create a Database   Database : `agencydb`    CREATE TABLE `tbl_visitors` ( `id` int ( 11 ) NOT NULL , `visitorname` varchar ( 30 ) NOT NULL , `visitoremail` varchar ( 30 ) NOT NULL , `visitormobile` varchar ( 30 ) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `tbl_visitors` -- INSERT INTO `tbl_visitors` (`id`, `visitorna