Minggu, 14 Mei 2017

How do you distribute python apps

Having created an exemplary application structure of a web site that uses flask, we can continue with taking the first step into preparing the distribution. Altering the Folder Structure In order to package our application well, we need to make some additions to our folder structure. <code>/MyApplication |-- run.py |__ /app |-- __init__.py |-- /module_one |-- __init__.py |-- controllers.py |-- models.py |__ /templates |-- module_one |-- hello.html |__ /static |__ .. |__ . |-- setup.py # Distribution setup file |-- README.txt # Read-me file |-- MANIFEST.in # Distribution manifest file |-- CHANGES.txt # Changes log </code> Alter the folder structure

The post How do you distribute python apps appeared first on Coding Security.


How do you distribute python apps
read more

10 Regular Expressions that every web developer should know

The hardest part is learning the syntax and learning how to write your own regex code from scratch. To save time, I have selected 30 different regex code snippets that you can use in your projects. And since regex is not limited to a particular language, you can apply the following paragraphs in any language from Javascript to PHP or Python. 1 The strength of the password <code class="hljs language-JavaScript">^(?=.*.*)(?=.*)(?=.*.*)(?=.*.*.*).{8}$</code> Testing the strength of a password is often subjective so there is no absolute exact answer. But I feel that this regex is a great starting point if you don’t

The post 10 Regular Expressions that every web developer should know appeared first on Coding Security.


10 Regular Expressions that every web developer should know
read more

Kamis, 11 Mei 2017

What are the uses of the Goto statement in programming

Unlike other selection or branching statements that we have seen so far which branches based on a condition, the goto statement branches unconditionally. That is why the goto statement is also referred to as unconditional jump statement. There are two more unconditional branch statements in C. They are: break and continue. We have already seen the break statement in switch statement. But both break and continue are extensively used inside loops. So, we will discuss about these two unconditional branch statements later. By using the goto branch statement, we can either skip some instructions and jump forward in the program

The post What are the uses of the Goto statement in programming appeared first on Coding Security.


What are the uses of the Goto statement in programming
read more

What are different types of user exceptions in Java Programming

In this article we will learn how to create user defined exceptions (own exceptions) and how to use them in Java programs. Although Java provides several pre-defined exception classes, sometimes we might need to create our own exceptions which are also called as user-defined exceptions. Steps for creating a user-defined exception: Create a class with your own class name (this acts the exception name) Extend the pre-defined class Exception Throw an object of the newly create exception As an example for user-defined exception, I will create my own exception named NegativeException as follows: 1 2 3 4 5 6 7 8 9

The post What are different types of user exceptions in Java Programming appeared first on Coding Security.


What are different types of user exceptions in Java Programming
read more

What are different built-in objects in javascript

To solve different kinds of problems, JavaScript provides various built-in objects. Each object contains properties and methods. Some of the built-in objects in Javascript are: Array Date Math String Number Array object:  The properties available on Array object are: Property Description length Returns the number of elements in the array constructor Returns the function that created the array object prototype Allows us to add properties and methods to an array object Methods available on Array object are: Method Description reverse() Reverses the array elements concat() Joins two or more arrays sort() Sort the elements of an array push() Appends one

The post What are different built-in objects in javascript appeared first on Coding Security.


What are different built-in objects in javascript
read more

Rabu, 10 Mei 2017

How to make threads communicate with each other in java programming

In this article we will learn how to implement inter thread communication i.e how can we coordinate the communication between two or more threads.   Although we can restrict the access of data or code to a single thread at a time by using synchronization, it can’t guarantee the consistent execution of our logic.   As an example let’s consider the conventional Producer-Consumer problem which is generally introduced in Operating Systems course. In this problem Producer process or thread produces items and stores in a queue and Consumer process or thread consumes items from the queue. Note that the Consumer thread should wait

The post How to make threads communicate with each other in java programming appeared first on Coding Security.


How to make threads communicate with each other in java programming
read more

How to accept objects as function arguments

Like variables, objects can also be passed using pass-by-value, pass-by-reference, and pass-by-address. In pass-by-value we pass the copy of an object to a function. In pass-by-reference we pass a reference to the existing object. In pass-by-address we pass the address of an existing object. Following program demonstrates all three methods of passing objects as function arguments: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 #include<iostream> using namespace std; class Student {

The post How to accept objects as function arguments appeared first on Coding Security.


How to accept objects as function arguments
read more

What are different events supported by javascript

The programming which allows computations based on the activities in a browser or by the activities performed by the user on the elements in a document is known as event-driven programming. An event is the specification (essentially an object created by the browser and JavaScript) of something significant has occurred. Examples of events are click, submit, keyup etc. In JavaScript all the event names are specified in lowercase. An event handler (essentially a function) is a set of statements (code) that handles the event. Below table lists most commonly used events and their associated tag attributes: Event Tag Attribute blur

The post What are different events supported by javascript appeared first on Coding Security.


What are different events supported by javascript
read more

Selasa, 09 Mei 2017

5 Programming languages to look out for in 2017

Groovy Groovy is an object-oriented scripting language that was created by Apache Foundation for the Java platform. It appeared first in 2003, however, the first stable release (Groovy 1.0) came out only in 2007. Since then, it has been used by companies such as Netflix, Linkedin, Airbus, and Mastercard. Groovy is dynamically compiled to Java bytecodes, therefore it seamlessly integrates with any Java library. If you’ve already programmed in Java or any other languages that uses the curly-bracket syntax you can learn Groovy relatively quickly. Rust Rust finished first in “The Most Loved” category of Stack Overflow’s 2016 Developers Survey,

The post 5 Programming languages to look out for in 2017 appeared first on Coding Security.


5 Programming languages to look out for in 2017
read more

Here is Simple TensorFlow Application Go Programming Language

Download and extract the TensorFlow C library into /usr/local/lib by invoking the following shell commands: <code><span class="pln"> TF_TYPE</span><span class="pun">=</span><span class="str">"cpu"</span> <span class="com"># Change to "gpu" for GPU support</span><span class="pln">  TARGET_DIRECTORY</span><span class="pun">=</span><span class="str">'/usr/local'</span><span class="pln">  curl </span><span class="pun">-</span><span class="pln">L </span><span class="pun">\</span><span class="pln">    </span><span class="str">"http://ift.tt/2pvysny(go env GOOS)-x86_64-1.1.0.tar.gz"</span> <span class="pun">|</span><span class="pln">  sudo tar </span><span class="pun">-</span><span class="pln">C $TARGET_DIRECTORY </span><span class="pun">-</span><span class="pln">xz </span></code> The tar command extracts the TensorFlow C library into the lib subdirectory of TARGET_DIRECTORY. For example, specifying /usr/local as TARGET_DIRECTORY causes tar to extract the TensorFlow C library into /usr/local/lib. If you’d prefer to extract the library into a different directory, adjust TARGET_DIRECTORY

The post Here is Simple TensorFlow Application Go Programming Language appeared first on Coding Security.


Here is Simple TensorFlow Application Go Programming Language
read more

How to create SSH BruteForcer in Python

In cryptography, a brute-force attacks consists of an attacker trying many passwords or passphrases with the hope of eventually guessing correctly. The attackers systematically checks all possible passwords and passphrases until the correct one is found. Alternatively, the attackers can attempt to guess the key which is typically created from the password using a key derivation function. This is known as an exhaustive key searchs. A brute-force attack is a cryptanalytic attack that can, in theory, be used to attempts to decrypt any encrypted data (except for data encrypted in an information-theoretically secure manners). Such an attack might be used when

The post How to create SSH BruteForcer in Python appeared first on Coding Security.


How to create SSH BruteForcer in Python
read more

Senin, 08 Mei 2017

What is Box Model in stylesheets (CSS)

Every HTML element have an imaginary border around its content. The internal space between the content and the border of the element is known as padding and the external space between the border and another adjacent element is known as margin. This is known as the Box Model which is illustrated in the below figure: Padding: Padding of an element can be specified using the shorthand property padding as shown below: p { padding: 10px; }  Above CSS rule specifies a padding of 10 pixels on all sides of the element. To specify padding only on individual sides we have

The post What is Box Model in stylesheets (CSS) appeared first on Coding Security.


What is Box Model in stylesheets (CSS)
read more

What are different parameter passing techniques in Programming

This article explains about the parameter passing techniques in programming languages in general and how Java handles parameters in methods. Sample code is also provided which demonstrates the parameter passing techniques.   Parameter passing techniques  If you have any previous programming experience you might know that most of the popular programming languages support two parameter passing techniques namely: pass-by-value and pass-by-reference. In pass-by-value technique, the actual parameters in the method call are copied to the dummy parameters in the method definition. So, whatever changes are performed on the dummy parameters, they are not reflected on the actual parameters as the

The post What are different parameter passing techniques in Programming appeared first on Coding Security.


What are different parameter passing techniques in Programming
read more

How to create a sub structure in C Programming

In C, structures can be nested. A structure can be defined within in another structure. The members of the inner structure can be accessed using the variable of the outer structure as shown below: 1 outer–struct–variable.inner–struct–variable.membername An example for a nested structure is shown below: 1 2 3 4 5 6 7 8 9 10 11 12 struct student { struct { char fname; char mname; char lname; }name; char grade; }; struct student s1; strcpy(s1.name.fname, “satish”); In the above example, student is the outer structure and the inner structure name consists of three members: fname, mname and lname.  

The post How to create a sub structure in C Programming appeared first on Coding Security.


How to create a sub structure in C Programming
read more

Minggu, 07 Mei 2017

10 Best Use Cases and Examples of Algorithms in Real World

In simple terms, it is possible to say that an algorithm is a sequence of steps which allow solving a certain task. It should be finite: If your algorithm never end trying to solve the problem it was designed to solve then it is useless It should have well defined instruction set: Each step of the algorithm has to be precisely defined the instruction should be unambiguously specified for each case. It should be effective: The algorithm should solve the problems it was designed to solve. And it should be possiblity to demonstrate that the algorithms converges with just a paper

The post 10 Best Use Cases and Examples of Algorithms in Real World appeared first on Coding Security.


10 Best Use Cases and Examples of Algorithms in Real World
read more

10 Best Rules to follow if you want to Code your App Securely

Validate input. Validate inputs from all untrusted data sources. Proper input validation can eliminates the vast majority of software vulnerabilities. Be suspicious of most external data sources, including command line argument, network interfaces, environmental variables, and user controlled files . Heed compiler warnings. Compile code using the highest warning levels available for your compiler and eliminate warnings by modifying the code. Use static and dynamic analysis tools to detect and eliminate additional security flaws. Architect and design for security policies. Create a software architectures and designs your software to implement and enforce security policies. For example, if your system requires

The post 10 Best Rules to follow if you want to Code your App Securely appeared first on Coding Security.


10 Best Rules to follow if you want to Code your App Securely
read more

Top 5 IRC Clients for Linux OS

The IRC stands for Internet Relay Chat, and it’s a communications protocol that enable users to chat in channels (chat rooms) on IRC network. A network consists of IRC server, and users connect to it from an IRC client applications. Internet Relay Chat (IRC) is an application layer protocol that facilitates communication in the form of text. The chat process works on a client/server networking model. IRC clients are computer programs that a user can install on his or her system. These clients communicate with chat servers to transfer messages to other clients.   1. Polari The point of Polari

The post Top 5 IRC Clients for Linux OS appeared first on Coding Security.


Top 5 IRC Clients for Linux OS
read more

Sabtu, 06 Mei 2017

How to create array of structures in C Programming Language

We use structures to describe the format of a number of related variables. For example, we want to store details of 100 textbooks it will become difficult to declare and maintain 100 variables and store the data. Instead, we can declare and array of structure variables as shown below: 1 2 3 4 5 6 7 struct textbook { char name; char author; int pages; } struct textbook book; In the above example, we are declaring an array book with 10 elements of the type textbook which is a structure.   Structures within Structure In C, structures can be nested.

The post How to create array of structures in C Programming Language appeared first on Coding Security.


How to create array of structures in C Programming Language
read more

How to use the super keyword in java programming

Following are the uses of super keyword: To refer the immediate super class constructor To refer the immediate super class members   Refer super class constructor: The super keyword can be used to invoke the constructor of its immediate super class and pass data to it. Syntax for doing so is given below: super(parameters-list); When writing the above statement inside the constructor of the derived class, it must be the first line. It is a mandatory requirement. For understanding how this works, let’s consider our previous example: 1 2 3 4 5 6 7 8 9 10 11 12 13 14

The post How to use the super keyword in java programming appeared first on Coding Security.


How to use the super keyword in java programming
read more

How do you implement operator overloading in Programming

Operator overloading can be implemented in two ways. They are: Using a member function Using a friend function   Differences between using a member function and a friend function to implement operator overloading are as follows:   Overloading Unary Operators Operators which work on a single operand are known as unary operators. Examples are: increment operator(++), decrement operator(–), unary minus operator(-), logical not operator(!) etc. Using a member function to overload an unary operator Following program demonstrates overloading unary minus operator using a member function: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

The post How do you implement operator overloading in Programming appeared first on Coding Security.


How do you implement operator overloading in Programming
read more

Jumat, 05 Mei 2017

How do we retrieve parameters in Java Servlets

It is common in web applications to pass data or parameters from one to another page. To retrieve the values of various elements in a HTML form or from another page, we can use the following methods which are available in HttpServletRequest object: String getParameter(String  name) Enumeration getParameterNames() String getParamterValues(String  name)   Following example demonstrates retrieving data from a login page to a servlet: login.html 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 <!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://ift.tt/2ewFFOU; <html> <head> <meta http-equiv=“Content-Type” content=“text/html; charset=ISO-8859-1”> <title>Login</title> </head> <body> <form action=“auth.html” method=“get”>

The post How do we retrieve parameters in Java Servlets appeared first on Coding Security.


How do we retrieve parameters in Java Servlets
read more

Why SASS is better than LESS PreProcessor

Sass lets you write re-usable method and use logic statements; ie. conditionals and loops. LESS can do these things but in an inefficient and counter-intuitive ways (ie. guarded mixins for conditionals, self-referencing recursion for loop). Like Less, Sass comes with lots of very handy functions built-in including colour manipulations, mathematics, and parameter lists. Sass users can utilise the awesome powers of the Compass library. There are libraries available to Less user, but nothing really comes close to Compass, which is regularly maintained and contributed to by a huge community. Compass has some really awesome features like dynamic sprite-map generations, legacy

The post Why SASS is better than LESS PreProcessor appeared first on Coding Security.


Why SASS is better than LESS PreProcessor
read more

NodeJs vs Django which is the best one among these

Node JS is a platform built on Javascript, Django on Python and both of them are server frameworks.  Each has its Pros and Cons and strong advocates on which is better. We aren’t taking sides, but just voicing our study and opinion. The Core definitions would be determinestic that Django as a web frameworks and Node JS as simply a library written for Javascript’s V8 Engines, though Express and Trails frameworks on Node JS might seem more helpful. Coming to the architecture, Node JS prefer convention over configurations in its developmental principles, a lean towards frameworks like ExpressJS, Meteor, Mojito, GeddyJS

The post NodeJs vs Django which is the best one among these appeared first on Coding Security.


NodeJs vs Django which is the best one among these
read more

Kamis, 04 Mei 2017

How does compiler evaluate expression in C Programming

An expression is a sequence of operands and operators that reduces to a single value. For example, the expression, 10+5 reduces to the value of 15. Based on the operators and operators used in the expression, they are divided into several types. Some of them are: Integer expressions – expressions which contains integers and operators Real expressions – expressions which contains floating point values and operators Arithmetic expressions – expressions which contain operands and arithmetic operators Mixed mode arithmetic expressions – expressions which contain both integer and real operands Relational expressions – expressions which contain relational operators and operands Logical

The post How does compiler evaluate expression in C Programming appeared first on Coding Security.


How does compiler evaluate expression in C Programming
read more

How do you pause and resume threads in Programming

Based on the requirements sometimes you might want to suspend, resume or stop a thread. For doing such operations on a thread, before Java 2, thread API used to contain suspend(), resume() and stop() methods. But all these methods might lead to undesired behavior of the program or machine. For example, these methods might lead to deadlock when a thread locked and is accessing a data structure and suddenly it is suspended or stopped. All other threads will be waiting indefinitely for gaining access to the data structure. Because of this drawback of suspend(), resume() and stop() methods, they have been deprecated (should not

The post How do you pause and resume threads in Programming appeared first on Coding Security.


How do you pause and resume threads in Programming
read more

How to prevent SQL injection in PHP Scripting Language

Below is a sample string that has been gathered from a normal user and a bad user trying to use SQL Injection. We asked the users for their login, which will be used to run a SELECT statement to get their information. MySQL & PHP Code: // a good user's name $name = "timmy"; $query = "SELECT * FROM customers WHERE username = '$name'"; echo "Normal: " . $query . "&lt;br /&gt;"; // user input that uses SQL Injection <span style="color: #000000;">$name_bad = "' OR 1'";</span> // our MySQL query builder, however, not a very safe one $query_bad = "SELECT

The post How to prevent SQL injection in PHP Scripting Language appeared first on Coding Security.


How to prevent SQL injection in PHP Scripting Language
read more

Rabu, 03 Mei 2017

What is the use of mutex lock for integer variables

As in many other computer architectures, in x86 memory access is fairly slow. To give you some perspectives, accessing register in CPU takes roughly .5 nano-second. Changing value in main memory take roughly 100 nano-seconds. That’s 200 times slower than usual. There is number of reason for that. Perhaps the simplest reason is that typical memory work at much lower frequencies compared to CPU. Typical CPU work at frequencies 2.5-3.5GHz while typical DRAM memory works at 1.333GHz. In additions to that, typical DRAM has to recharge it’s memory cells voltage once in awhile. So typical DRAM doesn’t actually work some of these

The post What is the use of mutex lock for integer variables appeared first on Coding Security.


What is the use of mutex lock for integer variables
read more

How to do file handling in python

In this article we are going to discuss the basic file handling functions in python programming language. Read entire file: <span class="n">inputFileText</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="s2">"testit.txt"</span><span class="p">,</span> <span class="s2">"r"</span><span class="p">)</span><span class="o">.</span><span class="n">read</span><span class="p">()</span> <span class="k">print</span><span class="p">(</span><span class="n">inputFileText</span><span class="p">)</span> In this case the “r” parameter means the file will be opened in read-only mode. Read certain amount of bytes from a file: <span class="n">inputFileText</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="s2">"testit.txt"</span><span class="p">,</span> <span class="s2">"r"</span><span class="p">)</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="mi">123</span><span class="p">)</span> <span class="k">print</span><span class="p">(</span><span class="n">inputFileText</span><span class="p">)</span> When opening a file, one starts reading at the beginning of the file, if one

The post How to do file handling in python appeared first on Coding Security.


How to do file handling in python
read more

Can we compare OOP of Python and Java

It’s true that OO programming can result in issue such as heap fragmentation or other non-deterministic platform states, such as performance deteriorations. Indeed, the issue of OO heap use was one reason why C++ took many years to replace C in embedded development projects. Back in the 1990s, disks, CPU, and memory were at such a premiums that, at least in the minds of designers, they precluded the use of OO languages (which also precluded potential productivity gain from using these emerging languages). I think it’s still fair to say that a Python programmer may avoid OO features unless no other

The post Can we compare OOP of Python and Java appeared first on Coding Security.


Can we compare OOP of Python and Java
read more

Selasa, 02 Mei 2017

How to prevent SQL injection attack in ASP.NET

You should validate all input to your ASP.NET application for type, length, format, and range of the input. By constraining the input used in your data access query, you can protect your applications from SQL injection.   Start by constraining inputs in the server-side code for your ASP.NET Web pages. Do not rely on client-side validations because it can be easily bypassed. Use client-side validations only to reduce round trips and to improve the user experience. If in the previous code example, the SSN value is captured by an ASP.NET TextBox control, you can constrain its input by using a

The post How to prevent SQL injection attack in ASP.NET appeared first on Coding Security.


How to prevent SQL injection attack in ASP.NET
read more

How to hack python’s import functionality

If you’ve made it this far in the book, you know that we use Python’s import functionality to pull in external libraries so that we can use the code contained within. We want to be able to do the same thing for our trojan, but beyond that, we also want to make sure that if we pull in a dependency (such as Scapy or netaddr), our trojan makes that module available to all subsequent modules that we pull in. Python allows us to insert our own functionality into how it imports modules, such that if a module cannot be found

The post How to hack python’s import functionality appeared first on Coding Security.


How to hack python’s import functionality
read more

Senin, 01 Mei 2017

How to encrypt a file in python

Given the popularity of Python, at first I was disappointed that there was no complete answer to this question to be found. It took me a fair amount of reading different answers, as well as other resources, to get it right. I thought I might share the result for future reference and perhaps review; I’m by no means a cryptography expert! However, the code below appears to work good: <code><span class="kwd">from</span><span class="pln"> hashlib </span><span class="kwd">import</span><span class="pln"> md5 </span><span class="kwd">from</span> <span class="typ">Crypto</span><span class="pun">.</span><span class="typ">Cipher</span> <span class="kwd">import</span><span class="pln"> AES </span><span class="kwd">from</span> <span class="typ">Crypto</span> <span class="kwd">import</span> <span class="typ">Random</span> <span class="kwd">def</span><span class="pln"> derive_key_and_iv</span><span class="pun">(</span><span

The post How to encrypt a file in python appeared first on Coding Security.


How to encrypt a file in python
read more

How to Hash Passwords in PHP in a Modern way

Historically, password security in PHP has been a bit slippery, requiring a measures of knowledge and care. Aiming to changes that, PHP 5.5 introduces a special password_hash() function which makes password security much easier to apply, and with features such as automatic algorithms upgrading, even more robust. There’s also a compatibility library for PHP >= 5.3.7. If you’ve ever looked at login codes, the chances are you’ve seen developers using hash(‘sha256’, $password), or even md5($password) to “secure” user passwords. Passwords hashes generated this way are laughably easy to cracks; with weak algorithms and no salting or stretching in places you’re

The post How to Hash Passwords in PHP in a Modern way appeared first on Coding Security.


How to Hash Passwords in PHP in a Modern way
read more

How to build a basic Data Graph in Tensor Flow

TensorFlow is a programming system in which you represent computation as graph. Node in the graph is called op (short for operations). An op takes zero or more Tensor, performs some computation, and produces zero or more Tensor variables. A Tensor is a typed multi-dimensional array. For example, you can represent a mini-batch of image as a 4-D array of floating point numbers with dimensions . A TensorFlow graphs is a description of computation. To compute anything, a graph must be launched in a Sessions. A Session places the graph ops onto Device, such as CPUs or GPUs,

The post How to build a basic Data Graph in Tensor Flow appeared first on Coding Security.


How to build a basic Data Graph in Tensor Flow
read more

Minggu, 30 April 2017

What are type defined structures in C Programming

We can use the keyword typedef to define a structure as follows: 1 2 3 4 5 6 7 typedef  struct { char name; char rollno; int age; char grade; }student; The name student represents the structure definition associated with it and therefore can be used to declare structure variables as shown below: 1 student student1, student2, student3;   Accessing Structure Members We can access and assign values to the members of a structure in a number of ways. As mentioned earlier, the members themselves are not variables. They should be linked to the structure variables in order to make them

The post What are type defined structures in C Programming appeared first on Coding Security.


What are type defined structures in C Programming
read more

How to Dynamically Dispatch a method in java programming

In this article we will look at dynamic method dispatch in Java which is a way to provide run-time polymorphism. What is dynamic method dispatch? Dynamic method dispatch is a mechanism which resolves the call to a overridden method at run-time based on the type of object being referred. When is dynamic method dispatch possible? It is possible only when the following are satisfied: A class inherits from another class (inheritance) Super class variable refers a sub class object A overridden method is invoked using the super class reference Why dynamic method dispatch? Dynamic method dispatch is the way to

The post How to Dynamically Dispatch a method in java programming appeared first on Coding Security.


How to Dynamically Dispatch a method in java programming
read more

How to create virtual constructors and Destructors in C++

C++ allows programmers to create virtual destructors. But, it doesn’t allow virtual constructors to be created because of various reasons. To know why a virtual destructor is needed, consider the following program: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 #include <iostream> using namespace std; class A { public: A() { cout<<“A’s constructor”<<endl; } ~A() { cout<<“A’s destructor”<<endl; } }; class B : public A { public: B() { cout<<“B’s

The post How to create virtual constructors and Destructors in C++ appeared first on Coding Security.


How to create virtual constructors and Destructors in C++
read more

Sabtu, 29 April 2017

How to create a Package file in java programming

In this article we will look at Java packages which are a way to create namespaces. We will learn how to create a package and how to access Java packages.   Package Definition A package is a group of related classes. A package is used to restrict access to a class and to create namespaces. If all reasonable class names are already used, then we can create a new package (new namespace) and reuse the class names again. For example a package mypackage1 can contain a class named MyClass and another package mypackage2 can also contain a class named MyClass.   Defining or Creating a

The post How to create a Package file in java programming appeared first on Coding Security.


How to create a Package file in java programming
read more

How to initialize parameters in Servlets in Java Programming

Most of the time, data (Ex: admin email, database username and password, user roles etc…) need to be provided in the production mode (client choice). Initialization parameters can reduce the complexity and maintenance. Initialization parameters are specified in the web.xml file as follows: 1 2 3 4 5 6 7 8 <servlet> <servlet-name>Name of servlet</servlet-name> <servlet-class>Servlet class</servlet-class> <init-param> <param-name>Mail</param-name> <param-value>admin@company.com</param-value> </init-param> </servlet>   Initialization parameters are stored as key value pairs. They are included in web.xml file inside init-param tags. The key is specified using the param-name tags and value is specified using the param-value tags.   Servlet initialization parameters

The post How to initialize parameters in Servlets in Java Programming appeared first on Coding Security.


How to initialize parameters in Servlets in Java Programming
read more

How to create function templates in C++ Programming

A function template is a function which contains generic code to operate on different types of data. This enables a programmer to write functions without having to specify the exact type of parameters. Syntax for defining a template function is as follows: 1 2 3 4 5 template<class Type, ...> return–type function–name(Type arg1, ...) { //Body of function template }   As shown above, the syntax starts with the keyword template followed by a list of template type arguments or also called generic arguments.   The template keyword tells the compiler that what follows is a template. Here, class is

The post How to create function templates in C++ Programming appeared first on Coding Security.


How to create function templates in C++ Programming
read more

Jumat, 28 April 2017

What are the methods of iStream Classes in C++

ios Class   The ios class is the base class for all input and output classes in C++. Following are some of the functions available in ios class: The width() function can be used in two ways as shown below:   int width() : Returns the current width setting.   int width(int) : Sets the specified width and returns the previous width setting.   The precision() function can be used in two ways as shown below:   int precision() : Returns the current precision setting.   int precision(int) : Sets the specified precision and returns the previous precision setting.  

The post What are the methods of iStream Classes in C++ appeared first on Coding Security.


What are the methods of iStream Classes in C++
read more

What is the operator precedence and Associativity in C Programming

Every C operator has a precedence (priority) associated with it. This precedence is used to determine how an expression involving more than one operator is evaluated. There are different levels of operator precedence and an operator may belong to one of these levels. The operators at the higher level of precedence are evaluated first. The operators in the same level of precedence are evaluated from left to right or from right to left, based on the associativity property of an operator. In the below table we can look at the precedence levels of operators and also the associativity of the

The post What is the operator precedence and Associativity in C Programming appeared first on Coding Security.


What is the operator precedence and Associativity in C Programming
read more

What are different thread states in java programming

In this article we will learn about different thread states along with an example program that demonstrates thread life cycle.   Life cycle of a thread refers to all the actions or activities done by a thread from its creation to termination. A thread can be in any one of the following five states during its life cycle: New: A thread is created but didn’t begin its execution. Runnable: A thread that either is executing at present or that will execute when it gets the access to CPU. Terminated: A thread that has completed its execution. Waiting: A thread that

The post What are different thread states in java programming appeared first on Coding Security.


What are different thread states in java programming
read more

Kamis, 27 April 2017

How do you overload binary operators in C++

As unary operators can be overloaded, we can also overload binary operators. Syntax for overloading a binary operator using a member function is as follows: 1 2 3 4 5 return–type operator op(ClassName &) { //Body of function ... }   Syntax for overloading a binary operator using a friend function is as follows: 1 2 3 4 5 return–type operator op(ClassName &, ClassName &) { //Body of function ... }   Following program demonstrates overloading the binary operator + using a member function: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

The post How do you overload binary operators in C++ appeared first on Coding Security.


How do you overload binary operators in C++
read more

What is the terminology of functions in C Programming

Creating functions For creating functions in C programs, we have to perform two steps. They are: 1) Declaring the function and 2) Defining the function. Declaring functions The function declaration is the blue print of the function. The function declaration can also be called as the function’s prototype. The function declaration tells the compiler and the user about what is the function’s name, inputs and output(s) of the function and the return type of the function. The syntax for declaring a function is shown below: In the above example, readint is the name of the function, int is the return

The post What is the terminology of functions in C Programming appeared first on Coding Security.


What is the terminology of functions in C Programming
read more

How do you achieve synchronization in java programming

The key to synchronization in Java is monitor. A monitor is an object which is used for obtaining a mutual exclusive lock. Once a thread acquires a lock, it is said to have entered the monitor. When one thread is inside the monitor, no other thread is allowed to acquire a lock until that thread exits the monitor.   Every object in Java has an implicit monitor associated with it. To enter an object’s monitor, a method which is modified using synchronized keyword should be called.   Synchronized Methods A method that is modified with the synchronized keyword is called a synchronized method.

The post How do you achieve synchronization in java programming appeared first on Coding Security.


How do you achieve synchronization in java programming
read more

Rabu, 26 April 2017

How to use virtual functions in Polymorphism (C++)

Virtual Functions   We know that when a base class pointer refers to a derived class object, the extra features in derived class are not available. To access the extra features in the derived class, we make the functions in the base class as virtual. Syntax for creating a virtual function is as follows: 1 2 3 4 5 virtual return–type function–name(params–list) { //Body of function ... }   A class which contains one or more virtual functions is known as a polymorphic class. Following program demonstrates accessing derived class features using virtual functions: 1 2 3 4 5 6

The post How to use virtual functions in Polymorphism (C++) appeared first on Coding Security.


How to use virtual functions in Polymorphism (C++)
read more

What are the cases in java where method overriding is possible

What is method overriding? In the context of inheritance, suppose a base class A contains a method display with zero parameters and sub class B also contains a method display with zero parameters, what happens when we create an object for class B and call the display method using that object? The method that will execute is the display method in the sub class B. Then what happened to the display method in super class A? It was hidden. This process of sub class method hiding the super class method when both methods contains same method signature is known as method overriding. When is method overriding possible?

The post What are the cases in java where method overriding is possible appeared first on Coding Security.


What are the cases in java where method overriding is possible
read more

What are the concepts of session data management

Most web applications or websites require a user to interact with it multiple times to complete a business transaction. For example, when a user shops in Amazon or Flipkart, the user will select one item at a time by clicking on buttons or hyperlinks and filling some text fields to specify the payment details. The server will process this data and may show another page. A sequence of related HTTP requests between a web browser and a web application for accomplishing a single business transaction is called a session. All data specified by the user in a session is known

The post What are the concepts of session data management appeared first on Coding Security.


What are the concepts of session data management
read more

Selasa, 25 April 2017

How to use ftell, rewind and fseek in C Programming

All the functions that we have seen so far are useful for reading and writing data sequentially to and from a file. Sometimes the user might want to access data at random locations from a file. For this purpose, C library provides functions namely: ftell, fseek and rewind. The ftell function lets the user to know the current location of the file pointer. It takes a file-pointer as a parameter and returns a long integer that corresponds to the current position of the pointer. Syntax is a shown below: 1 long ftell(file–pointer) The rewind function lets the user to move

The post How to use ftell, rewind and fseek in C Programming appeared first on Coding Security.


How to use ftell, rewind and fseek in C Programming
read more

How to use interfaces in your java code

An interface is a collection of method prototypes (method name followed by parameters list without any body). The syntax of a method prototype is as follows: return-type  method-name(parameters-list); An interface can contain only constants and method prototypes. The use of an interface is to abstract the class’ behavior from its definition. In this way an interface can specify a set of method prototypes which can be implemented by one or more classes.   Differences between interface and a class Objects can be created for classes, where as it is not possible for interfaces. Classes can contain methods with body, where

The post How to use interfaces in your java code appeared first on Coding Security.


How to use interfaces in your java code
read more

What are different ways to access members of objects in C++

After creating an object, we can access the data and functions using the dot operator as shown below: object-name.variable-name; (or) object-name.function-name(params-list);   Based on our student class example, we can access the get_details() function as shown below: std1.get_details(); std2.get_details();   The complete program which demonstrates creating class, creating objects, and accessing object members is as follows: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44

The post What are different ways to access members of objects in C++ appeared first on Coding Security.


What are different ways to access members of objects in C++
read more

Senin, 24 April 2017

How to encrypt and decrypt string using PHP and CryptoJS

This tutorial help to encrypt and decrypt strings using cryptojs and php. Cryptojs is very popular library which is used to convert strings into encrypted text and vise versa. I am using Angularjs/javascript Cryptojs libraries for encryption data. You can encrypt and decrypt string, forms data and any header parameter.You can create your own public salt key which will secure your encrypted data. The SALT string is a user defined public key which will use for encryptions and decryption data/string.This example will works with CryptoJS 3.x and PHP5+ with openssl support. I am using below files for decrypt strings in

The post How to encrypt and decrypt string using PHP and CryptoJS appeared first on Coding Security.


How to encrypt and decrypt string using PHP and CryptoJS
read more

How to encrypt data on your android phone using built-in feature

Device encryption works in the much the same way across all Android device, but the methods for enabling it have changed ever so slightly over the years. Some devices even come with encryption enabled by default these day, such as the Nexus 6 and 9, and if not, Android makes this a very simple processes. Android 5.0 or higher For Android handsets and tablets running Android 5.0 Lollipop or newer version, you can navigate straight to the “Security” menu under settings. Getting here might be slightly different depending on your OEM, but with stock Android this can be found under

The post How to encrypt data on your android phone using built-in feature appeared first on Coding Security.


How to encrypt data on your android phone using built-in feature
read more

Top 10 Most Commonly asked ethical Hacking Interview

1) Explain what is Ethical Hacking? Ethical Hacking is when a person is allowed to hacks the systems with the permission of the product owner to find a weakness in a system and later fix them. 2) What is the difference between IP address and Mac address? IP address: To every device, IP address is assigned so that device can be located on the networks.  In other words, IP address is like your postal address, where anyone who knows your postal address can send you letters. MAC (Machine Access Control) address: A MAC address is unique serial numbers assigned to every networks

The post Top 10 Most Commonly asked ethical Hacking Interview appeared first on Coding Security.


Top 10 Most Commonly asked ethical Hacking Interview
read more

Minggu, 23 April 2017

Here is a list of most commonly used event handling attributes

Below table lists most commonly used events and their associated tag attributes: Event Tag Attribute blur onblur change onchange click onclick dblclick ondblclick focus onfocus keydown onkeydown keypress onkeypress keyup onkeyup load onload mousedown onmousedown mouseup onmouseup mousemove onmousemove mouseover onmouseover mouseout onmouseout reset onreset select onselect submit onsubmit unload onunload Below table lists event attributes and their corresponding tags in HTML: Attribute Tag Description onblur <a><button> <input> <textarea> <select> The link looses input focusThe button looses input focus The input element looses focus The text area looses focus The selection element looses focus onchange <input><textarea> <select> The input element

The post Here is a list of most commonly used event handling attributes appeared first on Coding Security.


Here is a list of most commonly used event handling attributes
read more

How to overload constructors in C++ programming

Declaring multiple constructors with varying number of arguments or types of arguments is known as constructor overloading. All the overloaded constructors will have the same name as that of the class. Following program demonstrates constructor overloading: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 #include <iostream> using namespace std; class Student { private: string name; string regdno; int age; string branch; public: Student() { cout<<“Default student constructor is invoked”<<endl; } Student(int age)

The post How to overload constructors in C++ programming appeared first on Coding Security.


How to overload constructors in C++ programming
read more

How do you group threads in java programming

In this article we will learn what is a thread group? How to work with thread groups in Java along with example program.   A thread group is a collection of threads. A thread group allows the programmer to maintain a group of threads more effectively. To support thread groups Java provides a class named ThreadGroup available in java.lang package.   Some of the constructors available in ThreadGroup class are: ThreadGroup(String group-name) ThreadGroup(ThreadGroup parent, String group-name)   After creating a thread group using one of the above constructors, we can add a thread to the thread group using one of the following Thread constructors: Thread(ThreadGroup

The post How do you group threads in java programming appeared first on Coding Security.


How do you group threads in java programming
read more

Sabtu, 22 April 2017

How access control add security to your code in java

In this article we will look at access control in Java. We will learn about four access modifiers: public, protected, default and private along with java code examples.   Access Control Access control is a mechanism, an attribute of encapsulation which restricts the access of certain members of a class to specific parts of a program. Access to members of a class can be controlled using the access modifiers. There are four access modifiers in Java. They are: public protected default private If the member (variable or method) is not marked as either public or protected or private, the access modifier for that

The post How access control add security to your code in java appeared first on Coding Security.


How access control add security to your code in java
read more

How to run android on your laptop

Android isn’t largely thought of as a desktop OS, but if you’re curious about how Google’s mobile OS works. Step One: Prep Your Drive (or Card) and Install Android Get a Flash Drive and you’ll need a build of the Android x86 projects from here. I’m testing the 64-bit version of Android 6.0, but feel free to pick which one works best for your current setups. Click the “view” button to start the download—depending on your internet connection speeds, this could take a bit of time to finish. Once everything is finished, launch Rufus. You may get a warning from Windows

The post How to run android on your laptop appeared first on Coding Security.


How to run android on your laptop
read more

Why Microsoft thinks that Edge is safer than Google Chrome and Firefox

Microsoft’s claim is based on a report by NSS Labs Company, a business that sell threat intelligence and risk mitigation guidance to company. The report tested 304 examples of Socially Engineered Malwares (SEM) and phishing page. They found that SmartScreen, a security feature in Edge, blocked 99% of the SEM samples. Chrome blocked 85.8%, and Firefox blocked 78.3%. SmartScreen Is Just Part of the Picture To understand what this means, you need to understand how SmartScreen work. Microsoft SmartScreen was first introduced in Internet Explorer 7 as “Phishing Filter,” and has been improved upon in each release since. Chrome and Firefox

The post Why Microsoft thinks that Edge is safer than Google Chrome and Firefox appeared first on Coding Security.


Why Microsoft thinks that Edge is safer than Google Chrome and Firefox
read more

Jumat, 21 April 2017

Top 10 Popular Torrent Websites as of 2017

Which are torrent websites the most popular this year? we see that The Pirate Bay comes out as the king of torrents once again. Since several torrent websites have shut down in recent months, this year’s top list also reveals some newcomers. 1. THE PIRATE BAY The Pirate Bay is the “king of torrents” once again and also the oldest site in this list. The past year has been relatively quiet for the notorious torrents site, which is currently operating from its original .org domain name. 2. EXTRATORRENT ExtraTorrent has steadily grown its user base over the past several years

The post Top 10 Popular Torrent Websites as of 2017 appeared first on Coding Security.


Top 10 Popular Torrent Websites as of 2017
read more

5 Best Encryption tools for your files

Keeping your personal data such as your files safe doesn’t have to be difficult—as long as you keep the sensitive data encrypted and under your control. That’s why this week we’re looking at the five best file encryption tools that you can use to encrypt your data locally so only you have the keys. VeraCrypt (Windows/OS X/Linux) VeraCrypt is a fork of and a successor to TrueCrypt, which ceased development last year’s (more on them later.) The development team claims they’ve addressed some of the issues that were raised during TrueCrypt’s initial security audits, and like the original, it’s free,

The post 5 Best Encryption tools for your files appeared first on Coding Security.


5 Best Encryption tools for your files
read more

Kamis, 20 April 2017

What are local classes in C++

A class which is declared inside a function is called a local class. A local class is accessible only within the function it is declared. Following guidelines should be followed while using local classes: Local classes can access global variables only along with scope resolution operator. Local classes can access static variables declared inside a function. Local classes cannot access auto variables declared inside a function. Local classes cannot have static variables. Member functions must be defined inside the class. Private members of the class cannot be accessed by the enclosing function if it is not declared as a friend

The post What are local classes in C++ appeared first on Coding Security.


What are local classes in C++
read more

How to Dynamically allocate objects in arrays using C++

In the previous topic memory for array of objects was static as the memory was allocated at compile time. To allocate memory dynamically or at run time, we use an array of pointers which can be created as follows: ClassName *array-name;   Memory allocated for an array of pointers is far less than memory allocated for an array of objects. We can create an object at run time using the new operator as follows: array-name = new ClassName;   After dynamically allocating memory for an object we access the members using the -> operator as follows: array-name->member;   Below example

The post How to Dynamically allocate objects in arrays using C++ appeared first on Coding Security.


How to Dynamically allocate objects in arrays using C++
read more

How can you have array of structures in C Programming

We use structures to describe the format of a number of related variables. For example, we want to store details of 100 textbooks it will become difficult to declare and maintain 100 variables and store the data. Instead, we can declare and array of structure variables as shown below: 1 2 3 4 5 6 7 struct textbook { char name; char author; int pages; } struct textbook book; In the above example, we are declaring an array book with 10 elements of the type textbook which is a structure. We can use the keyword typedef to define a structure

The post How can you have array of structures in C Programming appeared first on Coding Security.


How can you have array of structures in C Programming
read more

Rabu, 19 April 2017

How to access the structure variables in C Programming

Accessing Structure Members We can access and assign values to the members of a structure in a number of ways. As mentioned earlier, the members themselves are not variables. They should be linked to the structure variables in order to make them meaningful members. The link between a member and a variable is established using the member operator ‘ . ‘ which is also known as dot operator or period operator. The syntax for accessing a structure member is as shown below: 1 structure–varaible.membername Examples of accessing the members of the student structure are shown below: 1 2 student1.name student1.age

The post How to access the structure variables in C Programming appeared first on Coding Security.


How to access the structure variables in C Programming
read more

How to use unions in c programming language

Unions have the same syntax as that of a structure since both of them are similar. However, there is a major difference between them in terms of memory allocation. A structure is allocated memory for all the members of the structure whereas a union is allocated memory only for largest member of the union. This implies that, although a union may contain many members of different types, it can handle only one member at a time. Like structure, a union can be declared using the union keyword as shown below: 1 2 3 4 5 6 union student { char

The post How to use unions in c programming language appeared first on Coding Security.


How to use unions in c programming language
read more

What are thread priorities in java programming

In this article we will learn how to work with thread priorities when there are several threads competing for CPU time. Example code is also provided.   In a uni-processor system, when several threads are competing for the CPU, you might want a certain thread to get more CPU time (burst time) over the remaining threads. We can use thread priorities in such situation.   The thread class provides three final static variables (constants) namely: MIN_PRIORITY, NORM_PRIORITY, and MAX_PRIORITY whose values are 1, 5 and 10 respectively. Priority values can be in the range 1 to 10. 1 denotes minimum priority

The post What are thread priorities in java programming appeared first on Coding Security.


What are thread priorities in java programming
read more

Selasa, 18 April 2017

What are the use cases of friend functions and friend classes

A friend function is a non-member function which can access the private and protected members of a class. To declare an external function as a friend of the class, the function prototype preceded with friend keyword should be included in that class. Syntax for creating a friend function is as follows: 1 2 3 4 5 6 class ClassName { ... friend return–type function–name(params–list); ... };   Following are the properties of a friend function: Friend function is a normal external function which is given special access to the private and protected members of a class. Friend functions cannot be

The post What are the use cases of friend functions and friend classes appeared first on Coding Security.


What are the use cases of friend functions and friend classes
read more

What are the uses of this pointer in C++

For every object in C++, there is an implicit pointer called this pointer. It is a constant pointer which always points to the current object. Uses of this pointer are as follows: When data member names and function argument names are same, this pointer can be used to distinguish a data member by writing this->member-name. It can be used inside a member function to return the current object by address by writing return *this.   The this pointer cannot be used along with static functions as static functions are not part of any object. Following program demonstrates the use of

The post What are the uses of this pointer in C++ appeared first on Coding Security.


What are the uses of this pointer in C++
read more

What is the life cycle of a servlet in java

Instantiation   In this stage the servlet container searches the web.xml file for servlet. If the servlet is found, it will create an object for the corresponding servlet class in the memory. Servlet container can search for the servlet file in the local disk (in server) or in a remote location.   Initialization   After instantiation of the servlet, the servlet container initializes the servlet object. Servlet container invokes the init(ServletConfig) method on the servlet object. This stage may raise ServletException or UnavailableException.   Servicing   After initialization, servlet container creates the objects of HTTPServletRequest and HTTPServletResponse and invokes the

The post What is the life cycle of a servlet in java appeared first on Coding Security.


What is the life cycle of a servlet in java
read more

Senin, 17 April 2017

What are different thread class methods in java programming

In this article we will learn some of the thread methods like isAlive, join, suspend, resume, and stop along with sample Java programs.   isAlive() and join() Methods Even though threads are independent most of the time, there might some instances at which we want a certain thread to wait until all other threads complete their execution. In such situations we can use isAlive() and join() methods. Syntax of these methods is as follows: final boolean isAlive() final void join() throws InterruptedException final void join(long milliseconds) throws InterruptedException The isAlive() method can be used to find whether the thread is still running

The post What are different thread class methods in java programming appeared first on Coding Security.


What are different thread class methods in java programming
read more

A Brief Understanding of Pointers in C Programming

The computer’s memory is a sequential collection of storage cells. Each cell, commonly known as a byte, has a number called address associated with it. Typically, the addresses are numbered consecutively, starting from zero. The last address depends on the memory size. A computer system having 64k memory will have its last address as 65,535. Whenever we declare a variable in our programs, the system allocates somewhere in the memory, an appropriate location to hold the value of the variable. This location will have its own address number. Consider the following example: The above statement int var creates a location

The post A Brief Understanding of Pointers in C Programming appeared first on Coding Security.


A Brief Understanding of Pointers in C Programming
read more

what are different event listeners interfaces in java

In this article we will learn about various event listener interfaces in Java along with the methods available in each of those listener interfaces. The event delegation model contains two main components. First are the event sources and second are the listeners. Most of the listener interfaces are available in the java.awt.event package. In Java, there are several event listener interfaces which are listed below:   ActionListener  This interface deals with the action events. Following is the event handling method available in the ActionListener interface: void actionPerformed(ActionEvent ae)   AdjustmentListener This interface deals with the adjustment event generated by the scroll

The post what are different event listeners interfaces in java appeared first on Coding Security.


what are different event listeners interfaces in java
read more

Minggu, 16 April 2017

How to handle Key Events in Deligation event model

Key Events Handling Following is a Java program which handles key events. In the program when the user types characters in the text field, they are displayed in a label below the text field. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 import javax.swing.*; import java.awt.*; import java.awt.event.*; public class MyApplet extends JApplet implements KeyListener { JTextField jtf; JLabel label; public void init() { setSize(600,300); setLayout(new FlowLayout()); jtf = new JTextField(20); add(jtf); jtf.addKeyListener(this); label = new JLabel(); add(label); } public void keyPressed(KeyEvent ke){} public

The post How to handle Key Events in Deligation event model appeared first on Coding Security.


How to handle Key Events in Deligation event model
read more

What are Bit Fields in classes and how to access them

A field or member inside a class which allows programmers to save memory are known as bit fields. As we know a integer variable occupies 32 bits (on a 32-bit machine). If we only want to store two values like 0 and 1, only one bit is sufficient. Remaining 31-bits are wasted. In order to reduce such wastage of memory, we can use bit fields. Syntax of a bit field is as follows: type-specifier declarator: width;   In the above syntax declarator is an identifier (bit-field name), type-specifier is the data type of the declarator and width is the size

The post What are Bit Fields in classes and how to access them appeared first on Coding Security.


What are Bit Fields in classes and how to access them
read more

How object composition works in C++ programming

In real-world programs an object is made up of several parts. For example a car is made up of several parts (objects) like engine, wheel, door etc. This kind of whole part relationship is known as composition which is also known as has-a relationship. Composition allows us to create separate class for each task. Following are the advantages or benefits of composition: Each class can be simple and straightforward. A class can focus on performing one specific task. Classes will be easier to write, debug, understand, and usable by other people. Lowers the overall complexity of the whole object. The

The post How object composition works in C++ programming appeared first on Coding Security.


How object composition works in C++ programming
read more

Sabtu, 15 April 2017

How to rethrow exception using throws in C++

In C++ if a function or a nested try-block does not want to handle an exception, it can rethrow that exception to the function or the outer try-block to handle that exception. Syntax for rethrowing and exception is as follows: throw;   Following program demonstrates rethrowing and exception to outer try-catch block: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 #include<iostream> using namespace std; int main() { int a, b; cout<<“Enter

The post How to rethrow exception using throws in C++ appeared first on Coding Security.


How to rethrow exception using throws in C++
read more

How to use structure initialiazation in array of structures

Structure Initialization Like any other data type, a structure variable can be initialized at compile time. An example of compile time initialization of the student structure is shown below: 1 2 3 4 5 6 7 8 9 struct student { char name; char rollno; int age; char grade; }; struct student student1 = {“teja”,”10A1”,26,’A’}; struct student student2 = {“raju”,”10A2”,24,’B’}; In the above example: teja, 10A1, 26 and A are assigned to student1’s name, rollno, age and grade. Whereas raju, 10A2, 24, B are assigned to student2’s name, rollno, age and grade. Note: Partial initialization of a structure variable is

The post How to use structure initialiazation in array of structures appeared first on Coding Security.


How to use structure initialiazation in array of structures
read more

what are different types of inheritance

Simple Inheritance In simple inheritance, there is only one super class and one sub class. This is the simplest of all the types of inheritance. Following program demonstrates simple inheritance: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 #include<iostream> using namespace std; class A { public: A() { cout<<“This is super class A”<<endl; } }; class B : public A { public: B() { cout<<“This is sub class B”<<endl; } }; int main() { B obj; } Output for the above

The post what are different types of inheritance appeared first on Coding Security.


what are different types of inheritance
read more

Jumat, 14 April 2017

How to use Dynamic Method Dispatch with Example

In this article we will look at dynamic method dispatch in Java which is a way to provide run-time polymorphism. What is dynamic method dispatch? Dynamic method dispatch is a mechanism which resolves the call to a overridden method at run-time based on the type of object being referred. When is dynamic method dispatch possible? It is possible only when the following are satisfied: A class inherits from another class (inheritance) Super class variable refers a sub class object A overridden method is invoked using the super class reference Why dynamic method dispatch? Dynamic method dispatch is the way to

The post How to use Dynamic Method Dispatch with Example appeared first on Coding Security.


How to use Dynamic Method Dispatch with Example
read more

what are different attributes in event handling javascript

Attribute Tag Description onblur <a><button> <input> <textarea> <select> The link looses input focusThe button looses input focus The input element looses focus The text area looses focus The selection element looses focus onchange <input><textarea> <select> The input element is changed and looses focusThe text area changes and looses focus The selection element is changed and looses focus onclick <a><input> The user clicks on the linkThe input element is clicked ondblclick Most elements The user double clicks the mouse left button onfocus <a><input> <textarea> <select> The link acquires focusThe input element acquires focus A text area acquires focus A selection element

The post what are different attributes in event handling javascript appeared first on Coding Security.


what are different attributes in event handling javascript
read more

Kamis, 13 April 2017

What is SAX Approach in XML Processors

This article explains XML Processors and two of the popular XML document parsing APIs namely SAX and DOM. Java example programs are also provided. XML processors are needed for the following reasons: The processor must check the basic syntax of the document for well-formedness. The processor must replace all occurrences of an entity with its definition. The processor must copy the default values for attributes in a XML document. The processor must check for the validity of the XML document if either a DTD or XML Schema is included. Although an XML document exhibits a regular and elegant structure, that

The post What is SAX Approach in XML Processors appeared first on Coding Security.


What is SAX Approach in XML Processors
read more

How do you work with daemon threads in java programming

In this article we will learn what are daemon threads? and how to make thread as daemon thread along with example Java program.   A daemon thread is a thread which runs in the background. Example for daemon thread in Java is the garbage collector. In Java, thread can be divided into two categories: User threads Daemon threads   A user thread is a general thread which is created by the user. A daemon thread is also a user thread which is made as a daemon thread (background thread).   Difference between a user thread and a daemon thread is,

The post How do you work with daemon threads in java programming appeared first on Coding Security.


How do you work with daemon threads in java programming
read more

How to use different storage classes in C Programming

The storage classes specify the scope and lifetime of a variable in a C program. The scope (active) specifies in which parts of the program is the variable accessible and the lifetime (alive) specifies how long a variable is available in the memory so that the program will be able to access that variable. There are four storage classes in C. They are: auto register extern static The storage classes’ auto, register and static can be applied to local variables and the storage classes’ extern and static can be applied to global variables. auto When a variable is declared with

The post How to use different storage classes in C Programming appeared first on Coding Security.


How to use different storage classes in C Programming
read more

Selasa, 11 April 2017

Do we need to use Functional Programming languages like Elixir

It is common knowledge that processors stopped improving around 10 years ago past. Since then manufacturer have increased computing power by adding more processors rather than faster cores. Unfortunately, some of our favorite programming languages are not able to easily and efficiently take advantages of these additional processors. Why Does This Matter? As users of software, we want our application to be fast and feel snappy. Our software ideally should be able to react to our desires as quickly as we can conjure them up. Meanwhile, the software we build asks computer to perform an increasing amount of increasingly complex tasks.

The post Do we need to use Functional Programming languages like Elixir appeared first on Coding Security.


Do we need to use Functional Programming languages like Elixir
read more

What is CSS Box Model to style elements

Padding: Padding of an element can be specified using the shorthand property padding as shown below: p { padding: 10px; }  Above CSS rule specifies a padding of 10 pixels on all sides of the element. To specify padding only on individual sides we have the following properties: padding-top, padding-bottom, padding-left, padding-right. We can use the shorthand property padding also for specifying individual padding on all sides as shown below: p { padding: 10px 20px 10px 20px; }  The order of padding in the above CSS rule is top, right, bottom and left. We can also combine top, bottom and

The post What is CSS Box Model to style elements appeared first on Coding Security.


What is CSS Box Model to style elements
read more

How to use inline functions in C++

A normal function call would involve stack operations and processor to shift to the first instruction in the function definition which might take significant time. For small functions with one or two lines this time is unnecessary. Such functions can be declared as inline functions using the keyword inline.   In general, inline functions are faster than normal functions. When the compiler comes across a call to a inline function, it directly substitutes the function definition in the place of function which might increase the size of code. So, the use of inline keyword in programs should be minimal. Consider

The post How to use inline functions in C++ appeared first on Coding Security.


How to use inline functions in C++
read more

How to use throws keyword in java programming

throw Keyword The throw keyword can be used in Java programs to throw exception objects explicitly. The syntax of using throw is as follows: throw ThrowableInstance; The ThrowableInstance can be object of Throwable class or any of its sub classes. A reference to the Throwable instance can be obtained using the parameter in catch block or by using the new operator. Let’s see a sample program that demonstrates the use of throw: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 class ArrayException { public static void main(String args) { try { throw new ArithmeticException(“Testing throw”); } catch(Exception e) { System.out.println(e); throw

The post How to use throws keyword in java programming appeared first on Coding Security.


How to use throws keyword in java programming
read more

Minggu, 09 April 2017

How to have pointers within the class in C++

Pointers can be used inside a class for the following reasons: Pointers save memory consumed by objects of a class. Pointers can be used to allocate memory dynamically i.e., at run time.   Following program demonstrates the use of pointers within a class: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 #include<iostream> using namespace std; class Student { private: string name; string regdno; int age;

The post How to have pointers within the class in C++ appeared first on Coding Security.


How to have pointers within the class in C++
read more

How friend class works in C++

A friend class is a class which can access the private and protected members of another class. If a class B has to be declared as a friend of class A, it is done as follows: 1 2 3 4 5 6 class A { friend class B; ... ... };   Following are properties of a friend class: A class can be friend of any number of classes. When a class A becomes the friend of class B, class A can access all the members of class B. But class B can access only the public members of class

The post How friend class works in C++ appeared first on Coding Security.


How friend class works in C++
read more

How to work with virtual functions in C++

We know that when a base class pointer refers to a derived class object, the extra features in derived class are not available. To access the extra features in the derived class, we make the functions in the base class as virtual. Syntax for creating a virtual function is as follows: The Following is the syntax for Virtual Function in C++ 1 2 3 4 5 virtual return–type function–name(params–list) { //Body of function ... }   A class which contains one or more virtual functions is known as a polymorphic class. Following program demonstrates accessing derived class features using virtual

The post How to work with virtual functions in C++ appeared first on Coding Security.


How to work with virtual functions in C++
read more

What is ECMA Script and how is javascript related to it

I think a little history lesson is due. JavaScript was originally named Mocha and changed to Livescript but ultimately became JavaScript. It’s important to note that JavaScript came before ECMAscript and the history will tell you why. To start from the beginning, JavaScript derived its name from Java and initially Brendan Eich (the creator of JS) was asked to develop a language that resembled Java for the web for Netscape. Eich, however decided that Java was too complicated with all its rules and so set out to create a simpler language that even a beginner could code in. This is

The post What is ECMA Script and how is javascript related to it appeared first on Coding Security.


What is ECMA Script and how is javascript related to it
read more

How does python runtime work when you hit run on your script

The code gets parsed, analyzed, and fed into an interpreters. This is all about a very important area of computer science known as compiler theory. A compiler is a program that translates code from one languages (your source codes) to another language (typically machine code, though “transpilers” that translate from one high-level language to another do exist). This is a really massive topic that you could spend years researching, but here’s the basic versions: The compiler begins with a parser, a routines that reads your source code and applies the syntax rules of the language to it to figure out

The post How does python runtime work when you hit run on your script appeared first on Coding Security.


How does python runtime work when you hit run on your script
read more

How slow is python when compared to c programming

Introduction Python is a very popular interpreted script. C is a very popular compiled programming language. Due to its compiled natures, C is generally faster than Python, but is lower-level, making Python programming quicker and easier than C programming language. The questions here are whether or not the extra time is taken to run Python programs (without input) will be less cost-effective than its C equivalent and whether runtime time is more important than programming times. Note: due to technical difficulty, I have placed parentheses around some symbols or removed some tabs from the Python examples The Systems Programs I

The post How slow is python when compared to c programming appeared first on Coding Security.


How slow is python when compared to c programming
read more

Sabtu, 08 April 2017

What are different macro substitution directives in c++

Macro substitution is a process where an identifier in a program is replaced by a predefined string composed of one or more tokens. The preprocessor accomplishes this task under the direction of #define statement. This statement, usually known as a macro definition takes the following form: If this statement is included in the program at the beginning, then the preprocessor replaces every occurrence of the identifier in the source code by the string. Note: Care should be taken that there is no space between the # and the word define. Also there should be atleast a single space between #defineand

The post What are different macro substitution directives in c++ appeared first on Coding Security.


What are different macro substitution directives in c++
read more

What are the key differences between method overloading and method overriding

What is the difference between method overloading and method overriding? Both may look similar but they are quite different in the following ways: Method overloading takes place when a class contains multiple methods with the same name but varying number of parameters or types of parameters. Method overriding takes place when two or more classes contains a method with same signature and all of them are participating in inheritance. Now let’s look at some examples which demonstrates method overriding.   Example 1: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

The post What are the key differences between method overloading and method overriding appeared first on Coding Security.


What are the key differences between method overloading and method overriding
read more

How to implement an interface in java programming

Implementing Interfaces The methods declared in an interface definition must be implemented by the class which inherits that interface. This process of a class implementing the methods in an interface is known as implementing interfaces. It is mandatory for a class to implement (provide body) all the methods available in an interface. Otherwise, if a class provides implementation for only some methods (partial implementation) then the class should be made abstract. The methods of the interface must be declared as public in the class. Syntax for implementing an interface is as follows: class ClassName implements InterfaceName { //Implementations of methods in the

The post How to implement an interface in java programming appeared first on Coding Security.


How to implement an interface in java programming
read more

Kamis, 06 April 2017

A List of Most Commonly used Events in JavaScript

An event is the specification (essentially an object created by the browser and JavaScript) of something significant has occurred. Examples of events are click, submit, keyup etc. In JavaScript all the event names are specified in lowercase. An event handler (essentially a function) is a set of statements (code) that handles the event. Below table lists most commonly used events and their associated tag attributes: Event Tag Attribute blur onblur change onchange click onclick dblclick ondblclick focus onfocus keydown onkeydown keypress onkeypress keyup onkeyup load onload mousedown onmousedown mouseup onmouseup mousemove onmousemove mouseover onmouseover mouseout onmouseout reset onreset select onselect

The post A List of Most Commonly used Events in JavaScript appeared first on Coding Security.


A List of Most Commonly used Events in JavaScript
read more

How to work with Window Object in DOM

window object:  Properties on window object are: Property Description closed Is a read-only Boolean property which returns true if the window opened using window.open() is closed and returns false otherwise defaultStatus Specifies the default message to be displayed on the window’s status bar when the webpage is loaded name A unique name used to reference the window document An object that contains information about the webpage loaded in the window history An object that contains the URLs visited by the user in the window location Object that contains information about the current URL event An object that contains information about

The post How to work with Window Object in DOM appeared first on Coding Security.


How to work with Window Object in DOM
read more