Ankith Reddy

Ankith Reddy

730 Articles Published

Articles by Ankith Reddy

Page 7 of 73

Referencing Subclass objects with Subclass vs Superclass reference

Ankith Reddy
Ankith Reddy
Updated on 11-Mar-2026 3K+ Views

In java inheritance some of the basic rules includes −Object relation of Superclass (parent) to Subclass (child) exists while child to parent object relation never exists.This means that reference of parent class could hold the child object while child reference could not hold the parent object.In case of overriding of non static method the runtime object would evaluate that which method would be executed of subclass or of superclass.While execution of static method depends on the type of reference that object holds.Other basic rule of inheritance is related to static and non static method overriding that static method in java ...

Read More

Implicit conversion from Char to Decimal in C#

Ankith Reddy
Ankith Reddy
Updated on 11-Mar-2026 2K+ Views

To implicitly convert char to a Decimal, firstly set a char.char c = 'p';To convert char to decimal, assign the value.decimal dec; dec = c;Let us see the above example.Exampleusing System; public class Demo {    public static void Main() {       char c = 'p';       decimal dec;       Console.WriteLine("Implicit conversion from Char to Decimal");       dec = c;       Console.WriteLine("Decimal : "+dec);    } }OutputImplicit conversion from Char to Decimal Decimal : 112

Read More

C# into keyword

Ankith Reddy
Ankith Reddy
Updated on 11-Mar-2026 166 Views

Set query in a select clause using the into operator.The following is our list with Employee details −IList employee = new List() {    new Employee() { EmpID = 1, EmpName = "Tom", EmpMarks = 90, Rank = 8} ,    new Employee() { EmpID = 2, EmpName = "Anne", EmpMarks = 60, Rank = 21 } ,    new Employee() { EmpID = 3, EmpName = "Jack", EmpMarks = 76, Rank = 18 } ,    new Employee() { EmpID = 4, EmpName = "Amy" , EmpMarks = 67, Rank = 20} , };Now, fetch employee name that ends ...

Read More

Java program to convert float decimal to Octal number

Ankith Reddy
Ankith Reddy
Updated on 11-Mar-2026 407 Views

We can convert any decimal number to its equivalent octal by following program.In this we reserve the reminder we get after divide the given number by 8 as it is the base of Octal and then reverse the order of reminders we have stored by multiplying each reminder by 10.Let understand by following example.Examplepublic class DecimalToOctal {    public static void main(String[] args) {       int decimal = 84;       int octalNumber = 0, i = 1;       while (decimal != 0) {          octalNumber += (decimal % 8) * i;          decimal /= 8;          i *= 10;       }       System.out.println("Octal of given decimal is " + octalNumber);    } }OutputOctal of given decimal is 124

Read More

sleep() function in PHP

Ankith Reddy
Ankith Reddy
Updated on 11-Mar-2026 849 Views

The sleep() function delays execution of the current script for short time period.Syntaxsleep(sec)Parameterssec− The number of seconds to delay the script.ReturnThe sleep() function returns zero on success.ExampleOutputThe following is the output.02:54:50 02:54:52 02:54:57

Read More

Convert.ToInt64 Method in C#

Ankith Reddy
Ankith Reddy
Updated on 11-Mar-2026 702 Views

Convert a specified value to a 64-bit signed integer using Convert.ToInt64 Method.Let us take a double value.double doubleNum = 193.834;Now, convert it to Int64 i.e. long.long res; res = Convert.ToInt32(doubleNum);Exampleusing System; public class Demo {    public static void Main() {       double doubleNum = 193.834;       long res;       res = Convert.ToInt32(doubleNum);       Console.WriteLine("Converted {0} to {1}", doubleNum, res);    } }OutputConverted 193.834 to 194

Read More

How to multiply a given number by 2 using Bitwise Operators in C#?

Ankith Reddy
Ankith Reddy
Updated on 11-Mar-2026 4K+ Views

A number can be multiplied by 2 using bitwise operators. This is done by using the left shift operator and shifting the bits left by 1. This results in double the previous number.A program that demonstrates multiplication of a number by 2 using bitwise operators is given as follows.Exampleusing System; namespace BitwiseDemo {    class Example {       static void Main(string[] args) {          int num = 25, result;          result = num

Read More

C# Enum Parse Method

Ankith Reddy
Ankith Reddy
Updated on 11-Mar-2026 2K+ Views

The Parse method in Enum converts the string representation of the name or numeric value of enum constants to an equivalent enumerated object.The following is our enumeration.enum Vehicle { Car, Bus, Truck, Motobike };Now, use the GetNames() method in a loop to get the enum values. Parse them using the Enum.Parse() method as shown below −Enum.Parse(typeof(Vehicle)Exampleusing System; public class Demo {    enum Vehicle { Car, Bus, Truck, Motobike };    public static void Main() {       Console.WriteLine("The enumeration...");       foreach (string v in Enum.GetNames(typeof(Vehicle))) {          Console.WriteLine("{0} = {1:D}", v, Enum.Parse(typeof(Vehicle), v)); ...

Read More

Remove an item from a Hashtable in C#

Ankith Reddy
Ankith Reddy
Updated on 11-Mar-2026 803 Views

The following is our Hashtable −Hashtable h = new Hashtable(); h.Add(1, "Jack"); h.Add(2, "Henry"); h.Add(3, "Ben"); h.Add(4, "Chris");To remove an item, use the Remove() method. Here, we are removing the 3rd element.h.Remove(3);Let us see the complete example.Exampleusing System; using System.Collections; public class Demo {    public static void Main() {       Hashtable h = new Hashtable();       h.Add(1, "Jack");       h.Add(2, "Henry");       h.Add(3, "Ben");       h.Add(4, "Chris");       Console.WriteLine("Initial list:");       foreach (var key in h.Keys ) {          Console.WriteLine("Key = {0}, ...

Read More

How to use StringBuilder in C#?

Ankith Reddy
Ankith Reddy
Updated on 11-Mar-2026 355 Views

With StringBuilder, you can expand the number of characters in the string. String cannot be changed once it is created, but StringBuildercan be expanded. It does not create a new object in the memory.Initialize StringBuilder.StringBuilder str = new StringBuilder();Let us see an example to learn how to work with StringBuilder in C#.Exampleusing System; using System.Text; public class Program {    public static void Main() {       StringBuilder str = new StringBuilder("Web World!!",30);       str.Replace("World", "Arena");       Console.WriteLine(str);    } }OutputWeb Arena!!Above the Replace() method of StringBuilder is used to to replace a string in C#.

Read More
Showing 61–70 of 730 articles
« Prev 1 5 6 7 8 9 73 Next »
Advertisements