Do We Need Forward Declarations in Java

Paul Richard
Updated on 21-Jun-2020 12:43:56

703 Views

Forward declarations means the declaration of a method or variable prior to its implementation. Such declaration is necessary in C/C++ programming language in order to be able to use a variable or object before its implementation. In case, if we want to use a library code, then we need to create its header file and use it. But this is not a case in Java.Java allows using a variable, class prior to its declaration and implementation.Java allows using libraries code without any need of header files.Following example showcases the same. Here we have used a class object before its declaration.Examplepublic ... Read More

Difference Between super and this in Java

Vikyath Ram
Updated on 21-Jun-2020 12:42:48

7K+ Views

Following are the notable differences between super() and this() methods in Java. super()this()Definitionsuper() - refers immediate parent class instance.this() - refers current class instance.InvokeCan be used to invoke immediate parent class method.Can be used to invoke current class method.Constructorsuper() acts as immediate parent class constructor and should be first line in child class constructor.this() acts as current class constructor and can be used in parametrized constructors.OverrideWhen invoking a superclass version of an overridden method the super keyword is used.When invoking a current version of an overridden method the this keyword is used.Example Live Democlass Animal {    String name;    Animal(String name) ... Read More

Listing Directories and Files Using C#

karthikeya Boyini
Updated on 21-Jun-2020 12:41:57

530 Views

The Directory class in C# has many methods to perform operations on directories and sub-directories −Sr.NoMethod & Description1CreateDirectory(String)Creates all directories and subdirectories in the specified path unless they already exist.2CreateDirectoryDirectorySecurity(String)Creates all the directories in the specified path, unless the already exist, applying the specified Windows security.3Delete(String)Deletes an empty directory from a specified path.4DeleteBoolean(String)Deletes the specified directory and, if indicated, any subdirectories and files in the directory.5EnumerateDirectories(String)Returns an enumerable collection of directory names in a specified path.6EnumerateDirectories(String, String)Returns an enumerable collection of directory names that match a search pattern in a specified path.To get the directory names, use the EnumerateDirectories method. ... Read More

Mathematical Functions in C#

karthikeya Boyini
Updated on 21-Jun-2020 12:41:40

2K+ Views

The System.Math class in C# provides methods are properties to perform mathematical operations, trigonometric, logarithmic calculations, etc.Some of its methods include −Sr.NoMethod & Description1Abs(Decimal)Returns the absolute value of a Decimal number.2Abs(Double)Returns the absolute value of a double-precision floating-point number.3Abs(Int16)Returns the absolute value of a 16-bit signed integer.4Abs(Int32)Returns the absolute value of a 32-bit signed integer.5Abs(Int64)Returns the absolute value of a 64-bit signed integer.6Abs(SByte)Returns the absolute value of an 8-bit signed integer.7Abs(Single)Returns the absolute value of a single-precision floating-point number.8Acos(Double)Returns the angle whose cosine is the specified number.9Asin(Double)Returns the angle whose sine is the specified number.10Atan(Double)Returns the angle whose tangent is ... Read More

Logical Operators on String in C#

George John
Updated on 21-Jun-2020 12:40:48

1K+ Views

The following are the logical operators that you can use on Strings in C#.OperatorDescriptionExample&&Called Logical AND operator. If both the operands are non zero then condition becomes true.(A && B) is false.||Called Logical OR Operator. If any of the two operands is non zero then condition becomes true.(A || B) is true.!Called Logical NOT Operator. Use to reverses the logical state of its operand. If a condition is true then Logical NOT operator will make false.!(A && B) is true.Let us see an example showing how to use logical AND operator on strings −Example Live Demousing System; using System.Collections.Generic; using System.Linq; ... Read More

Different Ways for Integer to String Conversion in Java

Fendadis John
Updated on 21-Jun-2020 12:40:05

407 Views

Following are the different ways to convert an Integer to String in Java.Using Integer.toString(int) − Convert an int to String using static toString() method of Integer class.String b = Integer.toString(125);Using String.valueOf(int) − Convert an int to String using static valueOf() method of String class.String b = String.valueOf(125);Using new Integer(int).toString() − Convert an int to String using toString() method of Integer object.String b = new Integer(125).toString();Using DecimalFormat(pattern).format(int) − Convert an int to String using DecimalFormat.format() method.String b = new DecimalFormat("#").format(125);Using StringBuilder().toString() − Convert an int to String using StringBuilder.toString() method.String b = new StringBuilder().append(125).toString();Using StringBuffer().toString() − Convert an int to String ... Read More

What is a Copy Constructor in C#

Samual Sam
Updated on 21-Jun-2020 12:39:00

4K+ Views

Copy Constructor creates an object by copying variables from another object.Let us see an example −Exampleusing System; namespace Demo {    class Student {       private string name;       private int rank;       public Student(Student s) {          name = s.name;          rank = s.rank;       }       public Student(string name, int rank) {          this.name = name;          this.rank = rank;       }       public string Display {     ... Read More

Structure of a Client-Server System

Ricky Barnes
Updated on 21-Jun-2020 12:37:22

6K+ Views

In client server computing, the clients requests a resource and the server provides that resource. A server may serve multiple clients at the same time while a client is in contact with only one server.The different structures for two tier and three tier are given as follows −Two - Tier Client/Server StructureThe two tier architecture primarily has two parts, a client tier and a server tier.The client tier sends a request to the server tier and the server tier responds with the desired information.An example of a two tier client/server structure is a web server. It returns the required web ... Read More

What are Types in C#

Ankith Reddy
Updated on 21-Jun-2020 12:36:45

197 Views

The types in C# include the following −Value TypesValue type variables can be assigned a value directly. They are derived from the class System.ValueType.The value types directly contain data. Some examples are int, char, and float, which stores numbers, alphabets, and floating point numbers, respectively. When you declare an int type, the system allocates memory to store the value.Reference TypesThe reference types do not contain the actual data stored in a variable, but they contain a reference to the variables.Pointer TypesPointer type variables store the memory address of another type. Pointers in C# have the same capabilities as the pointers ... Read More

Single Processor Systems

Alex Onsman
Updated on 21-Jun-2020 12:36:31

19K+ Views

A single processor system contains only one processor. So only one process can be executed at a time and then the process is selected from the ready queue. Most general purpose computers contain the single processor systems as they are commonly in use.A single processor system can be further described using the diagram below −As in the above diagram, there are multiple applications that need to be executed. However, the system contains a single processor and only one process can be executed at a time.Differences Between Single Processor and Multiprocessor SystemsThere are many differences between single processor and multiprocessor systems.Some ... Read More

Advertisements