Programming Articles - Page 2542 of 3363

What are the restrictions on increment and decrement operators in java?

Venkata Sai
Updated on 30-Jul-2019 22:30:26

1K+ Views

The increment operator increments the value of the operand by 1 and the decrement operator decrements the value of the operand by 1. We use these operators to increment or, decrement the values of the loop after executing the statements on a value.Example Live Demopublic class ForLoopExample {    public static void main(String args[]) {       //Printing the numbers 1 to 10       for(int i = 1; i=1; i--) {          System.out.print(" "+i);       }    } }Output1 2 3 4 5 6 7 8 9 10 10 9 8 7 6 ... Read More

Differentiate between the prefix and postfix forms of the ++ operator in java?

Venkata Sai
Updated on 30-Jul-2019 22:30:26

4K+ Views

Java provides two operators namely ++ and --, to increment and decrement values by 1 respectively.There are two variants of these operators −Pre-increment/decrement − This form, increments/decrements the value first, and then performs the specified operation.ExampleIn the following example, the initial value of the variable i is 5. We are printing the incremented value of it using the pre increment operator.Since we are using the pre increment operator, the value of i is incremented then printed. Live Demopublic class ForLoopExample {    public static void main(String args[]) {       int i = 5;       System.out.println(++i);     ... Read More

Are true and false keywords in java?

Venkata Sai
Updated on 30-Jul-2019 22:30:26

1K+ Views

Keywords − Keywords in Java convey a special meaning to the compiler therefore, these cannot be used as identifiers. Java provides a set of 50 keywords.abstractcontinuefornewswitchassertdefaultgotopackagesynchronizedbooleandoifprivatethisbreakdoubleimplementsprotectedthrowbyteelseimportpublicthrowscaseenuminstanceofreturntransientcatchextendsintshorttrycharfinalinterfacestaticvoidclassfinallylongstrictfpvolatileconstfloatnativesuperwhileReserved words − Among the list of key words list mentioned above the key words goto and const are currently not in use. They are reserved words (for the future use).The true false and null − True, false and null represents certain values in Java, they are used as literals. They are not considered as keywords.Still, you cannot use them as identifiers in Java if you try to do so, a compile time error will ... Read More

Using List as Stack and Queues in Python

karthikeya Boyini
Updated on 30-Jul-2019 22:30:26

7K+ Views

In this article, we will learn about Stack & Queue structures in Python 3.x. Or earlier. Here we will discuss the working and modification within these data structures −This includes −Insertion operation (Push, Enqueue)Deletion operation (Pop, Dequeue)Display / Traversing OperationPrerequisites: List & List OperationsRelated Data Structure: List ManipulationRelated ImagesStackIn stacks, objects are stored one over another, and these objects get removed in the reverse order of the arrival i.e. LIFO concept is followed. LIFO means Last in First Out type arrangement is followed in the Stack data structure.Operations on a Stack −Addition / Appending of Element: This increases the stack ... Read More

Elaborate the legal operands of the instance of operator in java?

Venkata Sai
Updated on 30-Jul-2019 22:30:26

180 Views

The instanceof operator in Java is used to find whether a reference is an instance of a Type i.e. class or an interface.Example Live Demopublic class InstanceOfExample {    public static void main(String args[]) {       String str = "hello";       boolean bool = str instanceof String;       System.out.println(bool);    } }OutputtrueLegal operands of the instanceof operatorThe following are the only legal operands of the instanceof operator −Left operand − It must be a reference representing an object.Right operand − It must be the name of Java class or, interface.Except these two if you use ... Read More

Using Set() in Python Pangram Checking

karthikeya Boyini
Updated on 30-Jun-2020 08:14:53

408 Views

In this article, we will learn how to determine whether a string is “pangram” or not in Python 3.x. Or earlier. A pangram string contains every letter in the list of English language alphabets . Let us look at the illustration below −Provided Input: str = 'This is the python blog on Tutorial point' Desired Output: No Provided Input : str='I want to contribute to a 'dxyzwuvghlkfmq' open source project' Desired Output: YesBy definition, a perfect pangram includes every letter of the ‘26 English alphabets’ exactly once. This tutorial doesn’t include the concept of ‘perfect pangram’.Now Let’s look at the ... Read More

vars() function in Python

Syed Javed
Updated on 30-Jun-2020 08:13:57

756 Views

vars() function belongs to the collection of inbuilt functions provided by the Python standard library. It returns the __dic__ attribute of an associated object to the console.Syntaxvars(object)Return TypeParametersvars() function accepts only one parameter. It takes an object as its parameter which can be any module, class or any object having __dict__ attribute associated with it.This parameter is optional in nature. In case the function is used without parameters A dictionary containing local symbol table is displayed.Exceptions InvolvedIf the argument passed doesn’t match the attribute, it raises the TypeError exception.ScopeVars() acts like locals() method when no argument is passed.The locals() method ... Read More

What are the rules to be followed while working with a switch statement in java?

Venkata Sai
Updated on 30-Jul-2019 22:30:26

2K+ Views

A switch statement allows a variable to be tested for equality against a list of values. Each value is called a case, and the variable being switched on is checked for each case.Syntaxswitch(expression) {    case value :       // Statements       break;    case value :       // Statements       break;       // You can have any number of case statements.    default :       // Statements }Rules to be followedWhile working with a switch statement keep the following points in mind −We must only use int, ... Read More

How many bits are used to represent Unicode, ASCII, UTF-16, and UTF-8 characters in java?

Venkata Sai
Updated on 30-Jul-2019 22:30:26

3K+ Views

In general, data is stored in a computer in the form of bits (1 or, 0). There are various coding schemes available specifying the set of bytes represented by each character.ASCII − Stands for American Standards Code for Information Interchange. It is developed by American standards association and is the mostly used coding system. It represents characters using 7 bits and has includes 128 characters: upper and lowercase Latin alphabet, the numbers 0-9, and some extra characters).Unicode (UTF) − Stands for Unicode Translation Format. It is developed by The Unicode Consortium. if you want to create documents that use characters ... Read More

Can we cast a double value to a byte in java?

Venkata Sai
Updated on 30-Jul-2019 22:30:26

4K+ Views

Java provides various datatypes to store various data values. It provides 7 primitive datatypes (stores single values) namely, boolean, byte, char, short, int, long, float, double and, reference datatypes (arrays and objects).Casting in JavaConverting one primitive data type into another is known as type casting. There are two types of casting −Widening− Converting a lower datatype to a higher datatype is known as widening. It is done implicitly.Narrowing− Converting a higher datatype to a lower datatype is known as narrowing. You need to do it explicitly using the cast operator (“( )”).Casting double to byteDouble is a higher datatype compared ... Read More

Advertisements