Thursday, 11 December 2014
Sunday, 9 November 2014
Language Fundamentals in c#.net
Language Fundamentals in c#.net
The programming language C# derives from C and C++; however apart from being entirely object oriented it is type safe and simple too. Many C# statements including expressions and operators have been taken directly taken from your favourite language An important point about C# is that it simplifies and modernizes C++ in the areas of classes, namespaces and exception handling. Much of complex features have not been included or in fact hidden in C# to make it easer to use.
using System;
class He llo {
public static void Main(String[] args)
{
Console.WriteLine("Hello World");
}
}
Console.WriteLine("Hello World");
}
}
Constants and Variables
A variable is a named memory location. They are programming elements that can change during program execution. Data that needs to be stored in memory & accessed at a later time are stored in variables. Instead of referring to the memory location by the actual memory address you refer to it with a variable name.
Variables are declared as follows
int a;
They can also be initialized at the time of declaration as follows:
int a = 10;
Constants are very similar to variables. The main difference is that the value contained in memory cannot be changed once the constant is declared. When you declare a constant its value is also specified and this value cannot be changed during program execution. Constants are used in situations where we need to keep the value in some memory location constant. If you use hard-coded values, and the value is changed then it has to be changed in all the locations in the code where it has been used. Instead if we are using constants, all we will need to do is to change the value of the constant. This would propagate the changes to our entire application.
Wednesday, 5 November 2014
Working with HTML
HTML stands for 'Hyper Text Mark-up Language' and is a simple language that anyone can learn and is used for making web pages.the html language is made up of tags that are enclosed in angle brakets, a webpage is completly enclosed within the html tags. Take a look below The first <HEAD> tag tells the browser that it is reading the head of a html document. The </HEAD> tag with the / in it tells the browser that the head part has ended.The first <TITLE> tag tells the browser that it is reading the title of a html document. The </TITLE> tag with the / in it tells the browser that the title has ended.
Example:
<html>
<head>
<title>Page Title</title>
</head>
<body>
<center>
<h1>Welcome</h1>
</center>
//center is used for to set the align
</body>
</html>
Apply Background Color
If you want to apply background color to web page,we are using bgcolor. and if you want to apply backgroundimage to web form we are using tag <body background="winter.jpg">
<html>
<head>
<title>GK DevelopmentS</title>
</head>
<body bgcolor="red">
<p>Hello</p>------------HTML code
<?php
echo "welcome"; ----------PHP code
//echo is used for to display the information
?>
</body>
</html>
Using Headers
If you want to apply headers to web page...we have different types from h1 to h6
Example:
<h1>Welcome</h1>
<h2>Welcome</h2>
<h3>Welcome</h3>
<h4>Welcome</h4>
<h5>Welcome</h5>
<h6>Welcome</h6>
use the <B></B> tags to make text <B>bold</B>
use the <EM></EM> tags to <EM>emphasise text</EM>
use the <U></U> tags to <U>underline text</U>
use the <I></I> tags to make<I>italic text</I>
use the <EM></EM> tags to <EM>emphasise text</EM>
use the <U></U> tags to <U>underline text</U>
use the <I></I> tags to make<I>italic text</I>
use the <strong></strong> used for bold
For Navigation from one page to another page:
<a href="register.html">Register</a> and <a href="http://www.bestsavings.in" target="_blank"> GK DevelopmentS</a>
For Image:
<img src="winter.jpg" />
Java Script
Java script is one of the script language.Java script is easy to learn..It is lightwaight object oriented programming language. This javascript is integrated with HTMLs and cross-platform.It works in client side.The JavaScript code is executed when the user submits the form, and only if all the entries are valid they would be submitted to the Web Server. If you want to implement the javascript we are using one tag i.e <script language="javascript"> </script> it is write in header part.
Javascript Syntax:
Alert box:
<html>
<head>
<script language="javascript">
function view()
{
alert("welcome");
}
{
alert("welcome");
}
</script>
</head>
<body>
<input type="submit" value="Click" onclick="return view();"/>
</body>
</html>
Form Validation
<html>
<head>
<title>Form Validation</title>
<script type="javascript">
function val()
{
if( document.getElementById("Name").value == "" )
{
alert( "Please Enter your name!" );
document.getElementById("Name").focus() ;
return false;
}
if(document.getElementById("EMail").value == "" )
{
alert( "Please provide your Email!" );
document.getElementById("Email").focus() ;
return false;
}
return true;
}
</script>
</head>
<body>
<form action="page.html" method="post">
<table cellspacing="2" cellpadding="2" border="1">
<tr><td align="right">Name</td> <td><input type="text" name="Name" /></td> </tr>
<tr> <td align="right">EMail</td> <td><input type="text" name="EMail" /></td> </tr>
<tr><td></td><td><input type="submit" value="register" onclick="return val()" /></td></tr>
</table>
</form>
</body>
</html>
Javascript for Only Number
function numbers()
{
var align = /^[0-9]+$/;
if(document.getElementById("mobile").value.match(align))
{
return true;
}
else
{
alert("enter numbers only");
return false;
}
}
Javascript for Only for Chars
function numbers()
{
var align = /^[a-zA-Z]+$/;
if(document.getElementById("name").value.match(align))
{
return true;
}
else
{
alert("enter chars only");
return false;
}
}
Javascript for both numbers and Chars
function numbers()
{
var align =/^[0-9a-zA-Z]+$/;
if(document.getElementById("IFCI").value.match(align))
{
return true;
}
else
{
alert("enter correct ifci code");
return false;
}
}
Javascript for Email validation
function numbers()
{
var align =/^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
if(document.getElementById("email").value.match(align))
{
return true;
}
else
{
alert("enter correct email id");
return false;
}
}
Learn Cascading Style Sheet
About CSS
Css is called as cascading style sheet.CSS is mainly used for to styles for every design presentation i.e. look and formatting and how to display the web page. It is simple style sheet language.css write in any HTML (Hyper Text Markup Language).By using this one to create the layouts, fonts, headers and different type of styles for page.
In css we are using 2 types of attributes
In css we are using 2 types of attributes
- Id (we are using ‘#’ for identifying): used for single and unique identifier.
Example:
<style>
#style
{
Color:red;
}
</style>
<div id=”style”>
Welcome
</div>
<style>
#style
{
Color:red;
}
</style>
<div id=”style”>
Welcome
</div>
2) Class (we are using ‘.’ For identifying): used for a group of elements
Example:
<style>
.style
{
Color:red;
}
p.style
{
Background-color:green;
}
</style>
{
Background-color:green;
}
</style>
<p class=”style”>
Welcome
</p>
Welcome
</p>
CSS are used in different ways
Way1: creating .css file(External)
Design.css
Way1: creating .css file(External)
Design.css
.page
{
Color:red;
Background-color:green;
Float:left;
}
Way 2: In header part
<head>
<style>
.page
{
Color:red;
Background-color:green;
Float:left;
}
</style>
<head>
<style>
.page
{
Color:red;
Background-color:green;
Float:left;
}
</style>
</head>
Way3: create in tag
<div style=”color:red;background-color:green;float:left”>
Welcome to GK developmentS
</div>
<div style=”color:red;background-color:green;float:left”>
Welcome to GK developmentS
</div>
How to create borders to paragraph:
<html>
<head>
<style>
p.thick
{
border-style:solid;
border-width:5px;
}
p.thin
{
border-style:solid;
border-width:medium;
}
p.normal
{
border-style:solid;
border-width:1px;
}
</style>
</head>
<html>
<head>
<style>
p.thick
{
border-style:solid;
border-width:5px;
}
p.thin
{
border-style:solid;
border-width:medium;
}
p.normal
{
border-style:solid;
border-width:1px;
}
</style>
</head>
<body>
<p class="thick">Welcome.</p>
<p class="thin">Gk.</p>
<p class="normal">developmentS.</p>
</body>
<p class="thick">Welcome.</p>
<p class="thin">Gk.</p>
<p class="normal">developmentS.</p>
</body>
</html>
Output:
Create border radius:
<html>
<head>
<style>
div
{
border:1px solid #a1a1a1;
background:#dddddd;
width:300px;
border-radius:25px;
}
</style>
</head>
<body>
<html>
<head>
<style>
div
{
border:1px solid #a1a1a1;
background:#dddddd;
width:300px;
border-radius:25px;
}
</style>
</head>
<body>
<div>Welcome</div>
</body>
</html>
</html>
Output:
Apply Shadow to div:
<html>
<head>
<style>
.shadow
{
width:300px;
height:100px;
color:yellow;
background-color:green;
box-shadow: 10px 10px 5px #888888;
}
</style>
</head>
<body>
<html>
<head>
<style>
.shadow
{
width:300px;
height:100px;
color:yellow;
background-color:green;
box-shadow: 10px 10px 5px #888888;
}
</style>
</head>
<body>
<div class="shadow">
</b>Welcome to GK developmentS</b>
</div>
</b>Welcome to GK developmentS</b>
</div>
</body>
</html>
</html>
Output:
Tuesday, 4 November 2014
Java interview Questions
package com.xyz.client ;
import java.io.File;
import java.net.URL;
Q) What is the Java Virtual Machine (JVM)?
A) JVM is a program which executes certain other programs, namely those containing Java bytecode instructions. JVMs are most often implemented to run on an existing operating system, but can also be implemented to run directly on hardware. A JVM provides a run-time environment in which Java bytecode can be executed, enabling features such as automated exception handling, which provides root-cause debugging information for every exception. A JVM is distributed along with Java Class Library, a set of standard class libraries (in Java bytecode) that implement the Java Application programming interface (API). These libraries, bundled together with the JVM, form theJava Runtime Environment (JRE).
Q) What are the usages of Java packages?
A) It helps resolve naming conflicts when different packages have classes with the same names. This also helps you organize files within your project. For example: java.io package do something related to I/O and java.net package do something to do with network and so on. If we tend to put all .java files into a single package, as the project gets bigger, then it would become a nightmare to manage all your files.
You can create a package as follows with package keyword, which is the first keyword in any Java program followed by import statements. The java.lang package is imported implicitly by default and all the other packages must be explicitly imported.
You can create a package as follows with package keyword, which is the first keyword in any Java program followed by import statements. The java.lang package is imported implicitly by default and all the other packages must be explicitly imported.
package com.xyz.client ;
import java.io.File;
import java.net.URL;
Q. What happens if you do not provide a constructor?
A)Java does not actually require an explicit constructor in the class description. If you do not include a constructor, the Java compiler will create a default constructor in the byte code with an empty argument. This default constructor is equivalent to the explicit “Pet(){}”. If a class includes one or more explicit constructors like “public Pet(int id)” or “Pet(){}” etc, the java compiler does not create the default constructor “Pet(){}”.
Q. Can you call one constructor from another?
A) Yes, by using this() syntax. E.g.
public Pet(int id)
{
this.id = id; // “this” means this object
this.id = id; // “this” means this object
}
public Pet (int id, String type)
{
this(id); // calls constructor public Pet(int id)
this(id); // calls constructor public Pet(int id)
this.type = type; // ”this” means this object
}
Q : What are the advantages of Object Oriented Programming Languages (OOPL)?
A)The Object Oriented Programming Languages directly represent the real life objects like Car, Jeep, Account,
Customer etc. The features of the OO programming languages like polymorphism, inheritance and encapsulation
make it powerful.
Customer etc. The features of the OO programming languages like polymorphism, inheritance and encapsulation
make it powerful.
Q) What is difference in final, finalize and finally keyword in Java?
A) final and finally are keyword, while finalize is method. final keyword is very useful for creating immutable class in Java by making a class final, we prevent it from being extended, similarly by making a method final, we prevent it from being overridden,. finalize() method is called by garbage collector, before that object is collected, but this is not guaranteed by Java specification. finally keyword is the only one which is related to error and exception handling and you should always have finally block in production code for closing connection and resources.
Q) What is difference betwwen object oriented programming and object based programming?
A) Object-oriented programming language supports all the features of OOPs and Object-based programming language doesn't support all the features of OOPs like Polymorphism and Inheritance.
- example: javascript as object based and java as object oriented
Q) Why JavaScript isn't an object-oriented programming (scripting) language?
A)Because it has no feature that fits the requirements of the definition of object-oriented programming:
var constructor = function() { };
constructor.prototype.text = "hello world";
alert(new constructor().text); // This alerts hello world
Q) what is a transient variable?
A) transient variable is a variable that cannot be serialized
Q) which containers use a border Layout as their default layout?
A) window, Frame and Dialog classes use a BorderLayout as their default layout.
Q) How are Observer and Observable used?
A) If a class which extends java.util.Observable that class Objects maintain a list of observers. When an Observable object is updated it invokes the update() method of each of its observers to notify the observers that it has changed state. The java.util.Observer interface is implemented by objects that observe Observable objects.
Q) What is synchronization and why is it important?
A) Synchronization is the process to control the access of multiple threads to shared resources. We will use 'synchornized' keyword to perform synchronization. Without synchronization, it is possible for one thread to modify a shared object while another thread is in the process of using or updating that object's value. This often leads to significant errors.
Q) Is null a keyword?
A)No, null is not a keyword, it is a value.
Q) Is sizeof a keyword?
A) sizeof is an operator, it is not a keyword.
Q) What is the Locale class?
A) The java.util.Locale class is used to represent a particular geographic, political, or cultural region.
Q) Can a double value be cast to a byte?
A) Yes, a double value can be cast to a byte.
Q) Can an unreachable object become reachable again?
A) Yes, an unreachable object may become reachable again. This can happen when the object's finalize() method is invoked and the object performs an operation which causes it to become accessible to reachable objects.
Q) why do you create interfaces, and when MUST you use one.?
A) You would create interfaces when you have two or more functionalities talking to each other. Doing it this way help you in creating a protocol between the parties involved.
Q) what are the main features of java?
A) The main features of java are
Platform Independent
Object oriented
Robust and secure
Type safe
High Performance.
Compiled and Interpreted
Object oriented
Robust and secure
Type safe
High Performance.
Compiled and Interpreted
Q) What is the Java API?
A) The Java API is a large collection of ready-made software components that provide many useful capabilities, such as graphical user interface (GUI) widgets.
Q) What is the Java Virtual Machine (JVM)?
A) The Java Virtual Machine is software that can be ported onto various hardware-based platforms.
Subscribe to:
Comments (Atom)

