In this article, we will see a menu driven program to check if the entered character is number, string or special character by Java programming language. We will be implementing the application using a switch case. To show you some instances Instance-1 Suppose the entered character is ‘a’ then the output should be “Entered character is a String”. Instance-2 Suppose the entered character is ‘1’ then the output should be “Entered character is a number”. Instance-3 Suppose the entered character is ‘$’ then the output should be “Entered character is a Special character”. Syntax To check whether ... Read More
Java Tricky Output Questions that are difficult to answer call for more work to be put into them. We will fall short if we attempt to respond to a challenging topic using common sense since such questions need specialized understanding. The majority of challenging java problems are based on perplexing ideas like loops, multi-threading, overloading, overriding, etc. Even when a question isn’t particularly challenging, we occasionally have trouble solving it. Despite the fact that the answer to the question is straightforward, we occasionally write code carelessly. Even if we don’t know the solution, we can still use analytical thinking ... Read More
Exceptions are the unusual events which disrupt the normal flow of execution of a program. When an exception occurs an object called exception object is generated, which contains details of exception like name, description, state of program. In this section, we are going to write a java program to handle divide by zero exception and how to handle multiple exceptions. Types of Exceptions− There are three types of exceptions − Checked exception − Checked exceptions are compile time exceptions i.e, they are checked during compilation of program.These cannot be ignored and must be handled by the programmer. ... Read More
In Java programming, there are scenarios where we need to extract individual digits from an integer for further manipulation or analysis. This tutorial will guide you through the process of extracting digits from a given integer using Java. Syntax while (num > 0) { int digit = num % 10; System.out.println(digit); num = num / 10; } The above is the syntax to extract digits from an integer in Java. We keep extracting the last digit by taking the remainder of the number with 10. We divide the number by 10 until it ... Read More
When we execute certain SQL queries (SELECT query in general) they return tabular data.The java.sql.ResultSet interface represents such tabular data returned by the SQL statements.i.e. the ResultSet object holds the tabular data returned by the methods that execute the statements which quires the database (executeQuery() method of the Statement interface in general).The ResultSet object has a cursor/pointer which points to the current row. Initially this cursor is positioned before first row.The next() method of the ResultSet interface moves the pointer of the current (ResultSet) object to the next row, from the current position.Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("Select ... Read More
The Map class's object contains key and value pairs. You can convert it into two list objects one which contains key values and the one which contains map values separately. To convert a map to list − Create a Map object. Using the put() method insert elements to it as key, value pairs Create an ArrayList of integer type to hold the keys of the map. In its constructor call the method keySet() of the Map class. Create an ArrayList of String type to hold the values of the map. In ... Read More
The Body Mass Index is the body mass in kilogram divided by the square of body height in meters. This is expressed as kg/m^2.A Java program that calculates the Body Mass Index (BMI) is given as follows.Exampleimport java.util.Scanner; public class Example { public static void main(String args[]) { Scanner sc = new Scanner(System.in); System.out.print("Input weight in kilogram: "); double weight = sc.nextDouble(); System.out.print("Input height in meters: "); double height = sc.nextDouble(); double BMI = weight / (height * height); ... Read More
In the modern era, computers have become a vital component of both commercial and private operations in the industry sector. As technological developments have accelerated, networking has become increasingly important. We have gradually transitioned from the first wired network technology to wireless networking technology. If we look at it now, we can see that networking affects everything. A computer network is a collection of interrelated devices that can share resources and exchange data with one another. A network's devices can be physically connected with wires or wirelessly with the help of radio waves or infrared signals. These devices employ a ... Read More
The task or process of importing other files in Python allows you to use functions, classes, or variables defined in those files within your current Python script. In this article, we will explore different ways to import other Python files, including built-in modules, user-defined modules, and importing specific functions or variables. By the end of this article, you will have a solid understanding of how to import and use code from other Python files in your current projects. Along the way, we will use code examples followed by lucid explanations to help you understand the above task. Importing a User-Defined ... Read More
Before getting into the docker container arguments we must know about python command line arguments and how they are accessed by the developer. Command line arguments are of great use when we want our python script to be controlled outside of the program. Access the python script’s command line arguments Step 1: Create a python script main.py Example # sys will allow us to access the passed arguments import sys # sys.argv[0] access the first argument passed that is the python script name print("File or Script Name is :", sys.argv[0]) # print arguments other than the file name ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP