Tuesday, August 31, 2010

Php Language

I. What is PHP? * PHP is an open-source server-side scripting language (freely downloadable from php.net and zend.com). PHP version 5.2.14 is available on Webserve (www.indiana.edu, www.iupui.edu, www.iun.edu, and www.iuk.edu). * You can create dynamic web pages with the PHP scripting language. A dynamic Web page interacts with the user, so that each user visiting the page sees customized information. PHP can also be used to create dynamic web pages that are generated from information accessed from a MySQL database. * You can embed PHP commands within a standard HTML page. PHP's syntax is similar to that of C and Perl, making it easy to learn for anyone with basic programming skills. * Another feature that PHP offers is connectivity to most of the common databases. PHP also offers integration with various external libraries, which allow the developer to do anything from generating PDF documents to parsing XML. Return to Top II. Using PHP on Webserve 1. Bang lines are not required and will be ignored if present. (This information is provided for historical purposes as the previous web server environment required bang lines.) 2. You should use .php as the file extension. This refers to only PHP files executed directly via a URL. Include files may use other extensions, such as .inc. If you have PHP files that currently use .php4 extensions, it is strongly recommended that you move toward using .php for these instead. 3. The script must have owner execute permission. For best security, we strongly recommend using permissions set to 700 (only owner has read, write, and execute privileges). For example, where "script.php" is the name of the file containing the script, change the file permission as follows. chmod 700 script.php Return to Top III. Using Sessions in the Webserve Environment By default, when PHP creates a session file it stores it in /tmp. In the Webserve environment, however, you should create a session directory in the login of your account and write the session information there. You will need to do occasional cleanup of any unused session files in your account that aren't deleted. Doing it this way will guarantee session persistence and will prevent potential server issues as a result of filling up /tmp. The specifics of how writing session files to /tmp can impact session persistence in the Webserve environment is provided below. As indicated above, when PHP creates a session file, the default behavior is to store it in /tmp. The /tmp directory is local and independent to each of the backend web servers. Hence, if a request is made to server_1, it stores the session file in its own /tmp. If a subsequent request for the same user ends up going to server_2, it won't find the original session file. The load balancers control how web requests are distributed across the backend web servers. These load balancers are configured to provide session persistence by tracking the IP address of the web browser and the backend web server to which a request is sent. The goal is to send all subsequent requests from a given web browser back to the same backend web server. As a result, normally the PHP session files in /tmp work as expected because the multiple requests for the same user is consistently sent to the same backend web server. However, the load balancers can only cache so much data and eventually older data is overwritten by new incoming requests. This can cause the loss of persistence information. Since PHP allows you to specify the location of the session files (i.e., other than /tmp) you should be sure to create a session directory in the login of your account and write session information there. Doing this will require you to periodically do cleanup of unused session files that are not deleted. Return to Top IV. Troubleshooting When running your scripts, if you receive a 500 Internal Server Error message, please check the following: 1. Check to make sure the file permission is set to 700 (read, write, and execute for owner only). 2. Check the Directory (folder) permission. Setting it to 777 will give you a 500 - Internal Server Error. Set it to 711. 3. When the file/directory permissions are set correctly, and you are still getting a 500 error, it is likely due to line compatibility between the program used to create/upload the file and the Linux server. To correct this, login to the account on Webserve via an SSH client that provides a command line interface and do the following: 1. Move to the directory where your php file is using the 'cd' command (e.g., cd www). 2. Open the file using an editor such as nano and save it by typing Ctrl + o This simple steps may solve your problem because it converts Windows CR/LF (carriage return/line feed) to Unix LF (line feed) or Mac CR to Unix LF. To prevent this problem, you need to change settings/preferences in the program you are using to develop php files. To set preferences in Dreamweaver, go to Edit => Preferences. Select Code Format or HTML Format (depending on the versions). Change Line Breaks to LF (Unix). Return to Top V. Sample PHP Code Place a file containing the code below inside the www directory of your Webserve account and save it as info.php To view the file, you would then provide the web site address to the file. For example: http://www.indiana.edu/~myaccount/info.php It will output information about the current state of PHP, which includes information about PHP compilation options and extensions, the PHP version, server information and environment (if compiled as a module), the PHP environment, OS version information, paths, master and local values of configuration options, HTTP headers, and the PHP License. Because every system is setup differently, phpinfo() can be used to check configuration settings and for available predefined variables on a given system . For more information see php.net's entry for phpinfo. Return to Top VI. Increasing the Memory Limit You can increase the memory limit with a php.ini file in the same directory as your php script. If you have multiple subdirectories, you will need to place the php.ini file in each subdirectory that has php scripts. In that php.ini file you can specify the memory_limit you wish to set by using: memory_limit = whatever integer you wish You can verify the memory_limit has changed by creating a php info file.

Saturday, August 28, 2010

Asp.net Interview Questions


#61607; .NET

- Difference between asp and asp.net
- How do you do exception management
- If you are using components in your application, how can you handle exceptions raised in a component
- Can we throw exception from catch block
- How do you relate an aspx page with its code behind page
- What are the types of assemblies and where can u store them and how
- What is difference between value and reference types
- Is array reference type / value type
- Is string reference type / value type
- What is web.config. How many web.config files can be allowed to use in an application
- What is differnce between machine.config and web.config
- What is shared and private assembly
- What are asynchronous callbacks
- How to write unmanaged code and how to identify whether the code is managed / unmanaged.
- How to authenticate users using web.config
- What is strong name and which tool is used for this
- What is gacutil.exe. Where do we store assemblies
- Should sn.exe be used before gacutil.exe
- What does assemblyinfo.cs file consists of
- What is boxing and unboxing
- Types of authentications in ASP.NET
- difference between Trace and Debug
- Difference between Dataset and DataReader
- What is custom tag in web.config
- How do you define authentication in web.Config
- What is sequence of code in retrieving data from database
- About DTS package
- What provider ADO.net use by default
- Where does web.config info stored? Will this be stored in the registry?
- How do you register the dotnet component or assembly?
- Difference between asp and asp.net
- Whis is stateless asp or asp.net?
- Authentication mechanism in dotnet
- State management in asp.net
- Types of values mode can hold session state in web.config
- About WebService
- What are Http handler
- What is view state and how this can be done and was this there in asp?
- Types of optimization and name a few and how do u do?
- About DataAdapters
- Features of a dataset
- How do you do role based security
- Difference between Response.Expires and Expires.Absolute
- Types of object in asp
- About duration in caching technique
- Types of configuration files and ther differences
- Difference between ADO and ADO.net
- About Postback
- If you are calling three SPs from a window application how do u check for the performance of the SPS

Tuesday, August 24, 2010

.NET Architecture


Most applications need data access at one point of time making it a crucial component when working with applications. Data access is making the application interact with a database, where all the data is stored. Different applications have different requirements for database access. VB .NET uses ADO .NET (Active X Data Object) as it's data access and manipulation protocol which also enables us to work with data on the Internet. Let's take a look why ADO .NET came into picture replacing ADO.

Evolution of ADO.NET

The first data access model, DAO (data access model) was created for local databases with the built-in Jet engine which had performance and functionality issues. Next came RDO (Remote Data Object) and ADO (Active Data Object) which were designed for Client Server architectures but, soon ADO took over RDO. ADO was a good architecture but as the language changes so is the technology. With ADO, all the data is contained in a recordset object which had problems when implemented on the network and penetrating firewalls. ADO was a connected data access, which means that when a connection to the database is established the connection remains open until the application is closed. Leaving the connection open for the lifetime of the application raises concerns about database security and network traffic. Also, as databases are becoming increasingly important and as they are serving more people, a connected data access model makes us think about its productivity. For example, an application with connected data access may do well when connected to two clients, the same may do poorly when connected to 10 and might be unusable when connected to 100 or more. Also, open database connections use system resources to a maximum extent making the system performance less effective.

Why ADO.NET?

To cope up with some of the problems mentioned above, ADO .NET came into existence. ADO .NET addresses the above mentioned problems by maintaining a disconnected database access model which means, when an application interacts with the database, the connection is opened to serve the request of the application and is closed as soon as the request is completed. Likewise, if a database is Updated, the connection is opened long enough to complete the Update operation and is closed. By keeping connections open for only a minimum period of time, ADO .NET conserves system resources and provides maximum security for databases and also has less impact on system performance. Also, ADO .NET when interacting with the database uses XML and converts all the data into XML format for database related operations making them more efficient.


The ADO.NET Data Architecture

Data Access in ADO.NET relies on two components: DataSet and Data Provider.

DataSet

The dataset is a disconnected, in-memory representation of data. It can be considered as a local copy of the relevant portions of the database. The DataSet is persisted in memory and the data in it can be manipulated and updated independent of the database. When the use of this DataSet is finished, changes can be made back to the central database for updating. The data in DataSet can be loaded from any valid data source like Microsoft SQL server database, an Oracle database or from a Microsoft Access database.

Data Provider

The Data Provider is responsible for providing and maintaining the connection to the database. A DataProvider is a set of related components that work together to provide data in an efficient and performance driven manner. The .NET Framework currently comes with two DataProviders: the SQL Data Provider which is designed only to work with Microsoft's SQL Server 7.0 or later and the OleDb DataProvider which allows us to connect to other types of databases like Access and Oracle. Each DataProvider consists of the following component classes:

The Connection object which provides a connection to the database
The Command object which is used to execute a command
The DataReader object which provides a forward-only, read only, connected recordset
The DataAdapter object which populates a disconnected DataSet with data and performs update


Data access with ADO.NET can be summarized as follows:

A connection object establishes the connection for the application with the database. The command object provides direct execution of the command to the database. If the command returns more than a single value, the command object returns a DataReader to provide the data. Alternatively, the DataAdapter can be used to fill the Dataset object. The database can be updated using the command object or the DataAdapter.

ADO .NET Data Architecture

Component classes that make up the Data Providers

The Connection Object

The Connection object creates the connection to the database. Microsoft Visual Studio .NET provides two types of Connection classes: the SqlConnection object, which is designed specifically to connect to Microsoft SQL Server 7.0 or later, and the OleDbConnection object, which can provide connections to a wide range of database types like Microsoft Access and Oracle. The Connection object contains all of the information required to open a connection to the database.

The Command Object

The Command object is represented by two corresponding classes: SqlCommand and OleDbCommand. Command objects are used to execute commands to a database across a data connection. The Command objects can be used to execute stored procedures on the database, SQL commands, or return complete tables directly. Command objects provide three methods that are used to execute commands on the database:

ExecuteNonQuery: Executes commands that have no return values such as INSERT, UPDATE or DELETE
ExecuteScalar: Returns a single value from a database query
ExecuteReader: Returns a result set by way of a DataReader object


The DataReader Object

The DataReader object provides a forward-only, read-only, connected stream recordset from a database. Unlike other components of the Data Provider, DataReader objects cannot be directly instantiated. Rather, the DataReader is returned as the result of the Command object's ExecuteReader method. The SqlCommand.ExecuteReader method returns a SqlDataReader object, and the OleDbCommand.ExecuteReader method returns an OleDbDataReader object. The DataReader can provide rows of data directly to application logic when you do not need to keep the data cached in memory. Because only one row is in memory at a time, the DataReader provides the lowest overhead in terms of system performance but requires the exclusive use of an open Connection object for the lifetime of the DataReader.

The DataAdapter Object

The DataAdapter is the class at the core of ADO .NET's disconnected data access. It is essentially the middleman facilitating all communication between the database and a DataSet. The DataAdapter is used either to fill a DataTable or DataSet with data from the database with it's Fill method. After the memory-resident data has been manipulated, the DataAdapter can commit the changes to the database by calling the Update method. The DataAdapter provides four properties that represent database commands:

SelectCommand
InsertCommand
DeleteCommand
UpdateCommand

When the Update method is called, changes in the DataSet are copied back to the database and the appropriate InsertCommand, DeleteCommand, or UpdateCommand is executed.

Monday, August 23, 2010

.Net Uses


cPanel is the industry leader for turning standalone servers into a fully automated point-and-click hosting platform. Tedious tasks are replaced by web interfaces and API-based calls. cPanel is designed with multiple levels of administration including admin, reseller, end user, and email-based interfaces. These multiple levels provide security, ease of use, and flexibility for everyone from the server administrator to the email account user.

cPanel is an organization that wins the loyalty of customers around the world by providing feature-rich applications backed by a team of developers, technical support engineers and quality assurance experts that provide stable builds, direct support, and fantastic customer service.

cPanel powers web hosting companies and organizations that have a need to automate and offer competitive hosting services.

cPanel Direct Licensing

cPanel can be installed on any server worldwide. If you currently operate your own servers and wish to purchase the cPanel software directly, it can be purchased online at the cPanel Store. Every direct software purchase receives priority support, installation support, and migration assistance.

Friday, August 20, 2010

.NET Framework and Languages


As mentioned on the .NET Framework page, .NET Framework is designed for cross-language compatibility.
Cross-language compatibility means .NET components can interact with each other irrespective of the languages they are written in. An application written in VB .NET can reference a DLL file written in C# or a C# application can refer to a resource written in VC++, etc. This language interoperability extends to Object-Oriented inheritance.

This cross-language compatibility is possible due to common language runtime. As you read on the .NET Framework page, when the .NET program is compiled, the output of the compiler is not an executable file but a file that contains a special type of code called the Microsoft Intermediate Language (MSIL). This MSIL is a
low-level language which is designed to be read and understood by the common language runtime. Because all .NET executables exist as IL, they can freely operate. The Common Language Specification defines the minimum standards that .NET language compliers must confirm to. Thus, any code compiled by a .NET complier can interoperate with the .NET Framework.

The Common Type System (CTS) defines the rules concerning data types and ensures that code is executed in a safe environment. Since all .NET applications are converted to IL before execution all primitive data types are represented as .NET types. This means that, a VB Integer and a C# int are both represented in IL code as System.Int32. Because both the languages use a common and interconvertible type system, it is possible to transfer data between components and avoid time-consuming conversions.

Languages supported by .NET Framework

The table below lists all the languages supported by the .NET Framework and describes those languages. The languages listed below are supported by the .NET Framework upto the year 2003. In future there may be other languages that the .NET Framework might support.



Thursday, August 19, 2010

.NET Frame Work Description


Many ISV's, enterprises and Microsoft product teams are successfully building on the new features Windows Workflow Foundation (WF), Windows Communication Foundation (WCF), Windows Presentation Foundation (WPF) and Windows CardSpace in the .NET Framework 3.0.

Microsoft plans to continue to invest in the .NET Framework developer platform and in support of existing users the .NET Framework 3.5 has a minimal number of breaking changes. So that existing applications built for .NET Framework 2.0 or .NET Framework 3.0 should continue to run without requiring changes.

The .NET Framework 3.5 adds new features in several major technology areas; including:
· Deep integration of Language Integrated Query (LINQ) and data awareness
· ASP.NET AJAX for quickly creating more efficient, more interactive and highly-personalized Web experiences that work across all the most popular browsers
· New web protocol support for building WCF services including AJAX, JSON, REST, POX, RSS, ATOM and several new WS-* standards
· Full tooling support for WF, WCF and WPF including the new workflow-enabled services technology
· New classes in the base class library (BCL) for the .NET Framework 3.5 address the most common customer requests.

.NET Framework 3.5 is planned to release at the end of 2007 and will ship with Visual Studio code name "Orcas" and will also continue to be available for separate download from MSDN.

The Microsoft .NET Framework 3.0 (which is formerly known as WinFX), is the new managed code programming model for Windows. It combines the power of the .NET Framework 2.0 with new technologies for building applications that have visually compelling user experiences, seamless communication across technology boundaries, and the ability to support a wide range of business processes.

These new technologies are Windows Presentation Foundation, Windows Communication Foundation, Windows Workflow Foundation, and Windows CardSpace (formerly code named "Infocard"). Microsoft plans to ship .NET Framework 3.0 as part of the Windows Vista operating system. In addition, Microsoft is making these technologies available on Windows XP and Windows Server 2003.

.NET Framework 3.0 can be installed on any of the following systems:
· Microsoft Windows 2003 Server Service Pack 1 (SP1)
· Windows XP SP2
· Windows Vista
Windows Vista comes with .NET Framework 3.0. There is no separate installation package required. The standalone .NET Framework 3.0 packages are not supported on Vista.

Requirements:

Processor
Minimum:
· 400 megahertz (MHz) Pentium processor

Recommended:
· 1 gigahertz (GHz) Pentium processor

RAM
Minimum:
· 96 megabytes (MB)

Recommended:
· 256 MB

Hard Disk: Up to 500 MB of available space may be required.

Display
Minimum:
· 800 x 600, 256 colors

Recommended:
· 1024 x 768 high color, 32-bit

Microsoft Connected Services Framework 3.0 Service Pack 1 Enterprise Edition

Microsoft Connected Services Framework is an integrated, server-based packaged software product for building and managing services by using a service-oriented architecture (SOA). For telecommunications operators and other service providers, CSF enables them to aggregate, provision, and manages converged communications services for their subscribers across multiple networks and a range of device types.

Microsoft Connected Services Framework 3.0 Service Pack 1 (SP1) addresses many of the high priority requests from our customers including a dramatic improvement in the setup and configuration of the CSF components. CSF 3.0 SP1 also includes support for WCF-based services, which includes WS-reliable messaging and better performance. Can be downloaded from Connected Services Framework 3.0 EE SP1

Requirements of Microsoft Connected Services Framework 3.0 Service Pack 1 Enterprise Edition:

· Internal Information Services 6.0
· Active Directory (Functional Level 2000)
· Microsoft .NET Framework 2.0
· Microsoft SQL Server 2000 Service Pack 4 (SP4), or 2005 SP1
· Windows Support Tools 2003 SP2
· Microsoft Operations Manager 2005 SP1
· UDDI 2.0
· Enterprise Single Sign-On 3.0
· Microsoft Clusting Server (if clustering is required)
· Microsoft Management Console 3.0
· Web Service Enhancement 3.0


Microsoft .NET Framework 3.0 Service Pack 1 Language Packs contain translated text, such as error messages, for languages other than English. Without the installation of a Language Pack, these messages are displayed in English by default.

Multiple language packs, each for a different language, can be installed on a single computer. Microsoft .NET Framework 3.0 SP1 Language Packs contain translated text, such as error messages, for each language.

The following Language Packs are designed for NET Framework 3.0 SP1 x86 ONLY : French , Greek , Spanish , Italian , German , Japanese.

The following Language Packs are designed for NET Framework 3.0 SP1 x64 ONLY : French , Spanish , Italian , German , Japanese.

.NET Framework 3.0 Service Pack 2 Update for Windows Server 2003 and Windows XP

There are some known incompatibilities in generic types using the BinaryFormatter or NetDataContractSerializer serialized and deserialized across a mixed .NET Framework 3.5 SP1 and .NET Framework 4 environment. Installing this update addresses these issues.


Microsoft .NET Framework 3.5 Service pack 1 Beta

Microsoft .NET Framework 3.5 service pack 1 is a cumulative update that contains many new features building incrementally upon .NET Framework 2.0, 3.0, 3.5, and includes .NET Framework 2.0 service pack 2 and .NET Framework 3.0 service pack 2 cumulative updates.

.NET Framework version 3.5 Service Pack 1 provides the following new features and improvements:

· ASP.NET Dynamic Data, which provides a rich scaffolding framework that allows rapid data driven development without writing code, and a new addition to ASP.NET AJAX that provides support for managing browser history (back button support). For more information, see What's New in ASP.NET and Web Development.

· Core improvements to the common language runtime that include better layout of .NET Framework native images, opting out of strong-name verification for fully trusted assemblies, improved application startup performance, better generated code that improves end-to-end application execution time, and opting managed code to run in ASLR (Address Space Layout Randomization) mode if supported by the operating system. Additionally, managed applications that are opened from network shares have the same behavior as native applications by running with full trust.

· Performance improvements to Windows Presentation Foundation, including a faster startup time and improved performance for Bitmap effects. Additional functionality for WPF includes better support for line of business applications, native splash screen support, DirectX pixel shader support, and the new WebBrowser control.

· ClickOnce application publishers can decide to opt out of signing and hashing as appropriate for their scenarios, developers can programmatically install ClickOnce applications that display a customized branding, and ClickOnce error dialog boxes support links to application-specific support sites on the Web.

· The Entity Framework is an evolution of the existing suite of ADO.NET data access technologies. The Entity Framework allows developers to program against relational databases in terms of application-specific domain models instead of the underlying database models. For more information see Getting Started with the Entity Framework. The Entity Framework introduces some additional features, including support for new SQL Server 2008 types, default graph serialization of Entities, and the first broad public release of the Entity Data Source. With this release, the Entity Framework supports the new date and file stream capabilities in SQL Server 2008. The graph serialization work helps developers who want to build Windows Communication Foundation (WCF) services that model full graphs as data contracts. The Entity Data Source provides a traditional data source experience for ASP.NET application builders who want to work with the Entity Framework.

· LINQ to SQL includes new support for the new date and file stream capabilities in SQL Server 2008.

· The ADO.NET Data Services Framework consists of a combination of patterns and libraries, which enable data to be exposed as a flexible REST (Representational State Transfer)-based data service that can be consumed by Web clients within a corporate network or across the Internet. The ADO.NET Data Services Framework makes data service creation over any data source. A conceptual view model of the underlying storage schema can easily be exposed through rich integration with the ADO.NET Entity Framework. Services created using the ADO.NET Data Services Framework, as well as compatible Windows Live (dev.live.com) services, can be easily accessed from any platform. For client applications running on Microsoft platforms, a set of client libraries are provided to make interaction with data services simple. For example, .NET Framework-based clients can use LINQ to query data services and a simple .NET Framework object layer to update data in the service.

· Windows Communication Foundation now makes the DataContract Serializer easier to use by providing improved interoperability support, enhancing the debugging experience in partial trust scenarios, and extending syndication protocol support for wider usage in Web 2.0 applications.

· The .NET Framework Data Provider for SQL Server (SqlClient) adds new support for file stream and sparse column capabilities in SQL Server 2008.

IMPORTANT: This beta release is for early testing and feedback. As a beta release, we recommend you only install the service pack on test computers. Prior to installation, you should carefully review the included readme file to be aware of any known issues with this release. For example, this service pack has some known compatibility issues with previous releases, including:
· Expression Blend (all versions)
· Silverlight 2 Beta 1 SDK
· Silverlight Tools Beta 1 for Visual Studio 2008

Wednesday, August 18, 2010

.NET And Its Importance


In the world of computers, software plays very important role just as hardware. This was recognized by Microsoft in earlier stages. Looking for new ways to improve their software, Microsoft made its software efficient not only to users but to developers as well.

.Net architecture not only helps businesses to make their existing software assets powerful but also to add new software services making them more productive. It can also prove effective in reducing application complexity and the related costs of developing and maintaining software.

.Net application development has helped to simplify development and customize of various enterprise level applications. This product comes as a part of Microsoft's Windows Operating System. .Net framework comes bundled with a lot of advantages, which makes it a widely used tool for .Net application development.

The .Net is built on the following Internet standards:

-UDDI, standard to search and discover Web Services
-XML, format for exchanging data between Internet Applications
-HTTP, communication protocol between Internet Applications
-SOAP, standard format for requesting Web Services

Advantages of .Net Software Development Services:

-Easy integration of any software into the Internet
-Supports directory services that can answer XML based questions
-Permits a wide variety of Internet devices to access data and applications
-Supports different levels of authentication of services such as passwords, wallets, and smart cards
-Ability to track visitors and report on the most requested web pages

The .Net framework is a set of huge library that encompasses various programming needs like user interface design, web development, data access, database connections, networking among many other algorithms. Hence the advent of .Net programming has simplified and made .Net application development very extensive.

Let's look at some important features of .Net framework:

-No language dependency
-Enhanced Security
-Easy deployment
-Easy Portability
-Interoperability

Commercial .Net Services that can be provided to Businesses:

- .Net Software Product Development
- .Net Desktop and Web Application Development
- Web Services based .Net Application development
- .Net custom control development
-.Net system design and application development
- .Net Architecture and design evaluation
- Developing web services using the .Net framework and the SOAP toolkit
- Migrating web and desktop applications to .Net
- Migration of application from .Net

.Net helps to develop your business, by generating large volumes of data that contain valuable information like individual facts about their customers, products, operations and people. By using .Net technology, web software outsourcing helps your business to do better.

Saturday, August 14, 2010

Java Interview Questions


What is meant by pass by reference and pass by value in Java?

Pass by reference means, passing the address itself rather than passing the value. Pass by value means passing a copy of the value.

If you’re overriding the method equals() of an object, which other method you might also consider?

hashCode()

What is Byte Code?

Or

What gives java it’s “write once and run anywhere” nature?

All Java programs are compiled into class files that contain bytecodes. These byte codes can be run in any platform and hence java is said to be platform independent.

Expain the reason for each keyword of public static void main(String args[])?

public- main(..) is the first method called by java environment when a program is executed so it has to accessible from java environment. Hence the access specifier has to be public.

static: Java environment should be able to call this method without creating an instance of the class , so this method must be declared as static.

void: main does not return anything so the return type must be void

The argument String indicates the argument type which is given at the command line and arg is an array for string given during command line.

What are the differences between == and .equals() ?

Or

what is difference between == and equals

Or

Difference between == and equals method

Or

What would you use to compare two String variables - the operator == or the method equals()?

Or

How is it possible for two String objects with identical values not to be equal under the == operator?

The == operator compares two objects to determine if they are the same object in memory i.e. present in the same memory location. It is possible for two String objects to have the same value, but located in different areas of memory.

== compares references while .equals compares contents. The method public boolean equals(Object obj) is provided by the Object class and can be overridden. The default implementation returns true only if the object is compared with itself, which is equivalent to the equality operator == being used to compare aliases to the object. String, BitSet, Date, and File override the equals() method. For two String objects, value equality means that they contain the same character sequence. For the Wrapper classes, value equality means that the primitive values are equal.

 public class EqualsTest {

public static void main(String[] args) {

String s1 = “abc”;
String s2 = s1;
String s5 = “abc”;
String s3 = new String(”abc”);
String s4 = new String(”abc”);
System.out.println(”== comparison : ” + (s1 == s5));
System.out.println(”== comparison : ” + (s1 == s2));
System.out.println(”Using equals method : ” + s1.equals(s2));
System.out.println(”== comparison : ” + s3 == s4);
System.out.println(”Using equals method : ” + s3.equals(s4));
}
}

Output
== comparison : true
== comparison : true
Using equals method : true
false
Using equals method : true

What if the static modifier is removed from the signature of the main method?

Or

What if I do not provide the String array as the argument to the method?

Program compiles. But at runtime throws an error “NoSuchMethodError”.

Why oracle Type 4 driver is named as oracle thin driver?

Oracle provides a Type 4 JDBC driver, referred to as the Oracle “thin” driver. This driver includes its own implementation of a TCP/IP version of Oracle’s Net8 written entirely in Java, so it is platform independent, can be downloaded to a browser at runtime, and does not require any Oracle software on the client side. This driver requires a TCP/IP listener on the server side, and the client connection string uses the TCP/IP port address, not the TNSNAMES entry for the database name.

What is the difference between final, finally and finalize? What do you understand by the java final keyword?

Or

What is final, finalize() and finally?

Or

What is finalize() method?

Or

What is the difference between final, finally and finalize?

Or

What does it mean that a class or member is final?

o final - declare constant
o finally - handles exception
o finalize - helps in garbage collection

Variables defined in an interface are implicitly final. A final class can’t be extended i.e., final class may not be subclassed. This is done for security reasons with basic classes like String and Integer. It also allows the compiler to make some optimizations, and makes thread safety a little easier to achieve. A final method can’t be overridden when its class is inherited. You can’t change value of a final variable (is a constant). finalize() method is used just before an object is destroyed and garbage collected. finally, a key word used in exception handling and will be executed whether or not an exception is thrown. For example, closing of open connections is done in the finally method.

What is the Java API?

The Java API is a large collection of ready-made software components that provide many useful capabilities, such as graphical user interface (GUI) widgets.

What is the GregorianCalendar class?

The GregorianCalendar provides support for traditional Western calendars.

What is the ResourceBundle class?

The ResourceBundle class is used to store locale-specific resources that can be loaded by a program to tailor the program’s appearance to the particular locale in which it is being run.

Why there are no global variables in Java?

Global variables are globally accessible. Java does not support globally accessible variables due to following reasons:

  • The global variables breaks the referential transparency
  • Global variables creates collisions in namespace.

How to convert String to Number in java program?

The valueOf() function of Integer class is is used to convert string to Number. Here is the code example:
String numString = “1000″;
int id=Integer.valueOf(numString).intValue();

What is the SimpleTimeZone class?

The SimpleTimeZone class provides support for a Gregorian calendar.

What is the difference between a while statement and a do statement?

A while statement (pre test) checks at the beginning of a loop to see whether the next loop iteration should occur. A do while statement (post test) checks at the end of a loop to see whether the next iteration of a loop should occur. The do statement will always execute the loop body at least once.

What is the Locale class?

The Locale class is used to tailor a program output to the conventions of a particular geographic, political, or cultural region.

Describe the principles of OOPS.

There are three main principals of oops which are called Polymorphism, Inheritance and Encapsulation.

Explain the Inheritance principle.

Inheritance is the process by which one object acquires the properties of another object. Inheritance allows well-tested procedures to be reused and enables changes to make once and have effect in all relevant places

What is implicit casting?

Implicit casting is the process of simply assigning one entity to another without any transformation guidance to the compiler. This type of casting is not permitted in all kinds of transformations and may not work for all scenarios.

Example

int i = 1000;

long j = i; //Implicit casting

Is sizeof a keyword in java?

The sizeof operator is not a keyword.

What is a native method?

A native method is a method that is implemented in a language other than Java.

In System.out.println(), what is System, out and println?

System is a predefined final class, out is a PrintStream object and println is a built-in overloaded method in the out object.

What are Encapsulation, Inheritance and Polymorphism

Or

Explain the Polymorphism principle. Explain the different forms of Polymorphism.

Polymorphism in simple terms means one name many forms. Polymorphism enables one entity to be used as a general category for different types of actions. The specific action is determined by the exact nature of the situation.

Polymorphism exists in three distinct forms in Java:
• Method overloading
• Method overriding through inheritance
• Method overriding through the Java interface

What is explicit casting?

Explicit casting in the process in which the complier are specifically informed to about transforming the object.

Example

long i = 700.20;

int j = (int) i; //Explicit casting

What is the Java Virtual Machine (JVM)?

The Java Virtual Machine is software that can be ported onto various hardware-based platforms

What do you understand by downcasting?

The process of Downcasting refers to the casting from a general to a more specific type, i.e. casting down the hierarchy

What are Java Access Specifiers?

Or

What is the difference between public, private, protected and default Access Specifiers?

Or

What are different types of access modifiers?

Access specifiers are keywords that determine the type of access to the member of a class. These keywords are for allowing
privileges to parts of a program such as functions and variables. These are:
Public : accessible to all classes
Protected : accessible to the classes within the same package and any subclasses.
Private : accessible only to the class to which they belong
Default : accessible to the class to which they belong and to subclasses within the same package

Which class is the superclass of every class?

Object.

Name primitive Java types.

The 8 primitive types are byte, char, short, int, long, float, double, and boolean.

What is the difference between static and non-static variables?

Or

What are class variables?

Or

What is static in java?

Or

What is a static method?

A static variable is associated with the class as a whole rather than with specific instances of a class. Each object will share a common copy of the static variables i.e. there is only one copy per class, no matter how many objects are created from it. Class variables or static variables are declared with the static keyword in a class. These are declared outside a class and stored in static memory. Class variables are mostly used for constants. Static variables are always called by the class name. This variable is created when the program starts and gets destroyed when the programs stops. The scope of the class variable is same an instance variable. Its initial value is same as instance variable and gets a default value when its not initialized corresponding to the data type. Similarly, a static method is a method that belongs to the class rather than any object of the class and doesn’t apply to an object or even require that any objects of the class have been instantiated.
Static methods are implicitly final, because overriding is done based on the type of the object, and static methods are attached to a class, not an object. A static method in a superclass can be shadowed by another static method in a subclass, as long as the original method was not declared final. However, you can’t override a static method with a non-static method. In other words, you can’t change a static method into an instance method in a subclass.

Non-static variables take on unique values with each object instance.

What is the difference between the boolean & operator and the && operator?

If an expression involving the boolean & operator is evaluated, both operands are evaluated, whereas the && operator is a short cut operator. When an expression involving the && operator is evaluated, the first operand is evaluated. If the first operand returns a value of true then the second operand is evaluated. If the first operand evaluates to false, the evaluation of the second operand is skipped.

How does Java handle integer overflows and underflows?

It uses those low order bytes of the result that can fit into the size of the type allowed by the operation.

What if I write static public void instead of public static void?

Program compiles and runs properly.

What is the difference between declaring a variable and defining a variable?

In declaration we only mention the type of the variable and its name without initializing it. Defining means declaration + initialization. E.g. String s; is just a declaration while String s = new String (”bob”); Or String s = “bob”; are both definitions.

What type of parameter passing does Java support?

In Java the arguments (primitives and objects) are always passed by value. With objects, the object reference itself is passed by value and so both the original reference and parameter copy both refer to the same object.

Explain the Encapsulation principle.

Encapsulation is a process of binding or wrapping the data and the codes that operates on the data into a single entity. This keeps the data safe from outside interface and misuse. Objects allow procedures to be encapsulated with their data to reduce potential interference. One way to think about encapsulation is as a protective wrapper that prevents code and data from being arbitrarily accessed by other code defined outside the wrapper.

What do you understand by a variable?

Variable is a named memory location that can be easily referred in the program. The variable is used to hold the data and it can be changed during the course of the execution of the program.

What do you understand by numeric promotion?

The Numeric promotion is the conversion of a smaller numeric type to a larger numeric type, so that integral and floating-point operations may take place. In the numerical promotion process the byte, char, and short values are converted to int values. The int values are also converted to long values, if necessary. The long and float values are converted to double values, as required.

What do you understand by casting in java language? What are the types of casting?

The process of converting one data type to another is called Casting. There are two types of casting in Java; these are implicit casting and explicit casting.

What is the first argument of the String array in main method?

The String array is empty. It does not have any element. This is unlike C/C++ where the first element by default is the program name. If we do not provide any arguments on the command line, then the String array of main method will be empty but not null.

How can one prove that the array is not null but empty?

Print array.length. It will print 0. That means it is empty. But if it would have been null then it would have thrown a NullPointerException on attempting to print array.length.

Can an application have multiple classes having main method?

Yes. While starting the application we mention the class name to be run. The JVM will look for the main method only in the class whose name you have mentioned. Hence there is not conflict amongst the multiple classes having main method.

When is static variable loaded? Is it at compile time or runtime? When exactly a static block is loaded in Java?

Static variable are loaded when classloader brings the class to the JVM. It is not necessary that an object has to be created. Static variables will be allocated memory space when they have been loaded. The code in a static block is loaded/executed only once i.e. when the class is first initialized. A class can have any number of static blocks. Static block is not member of a class, they do not have a return statement and they cannot be called directly. Cannot contain this or super. They are primarily used to initialize static fields.

Can I have multiple main methods in the same class?

We can have multiple overloaded main methods but there can be only one main method with the following signature :

public static void main(String[] args) {}

No the program fails to compile. The compiler says that the main method is already defined in the class.

Explain working of Java Virtual Machine (JVM)?

JVM is an abstract computing machine like any other real computing machine which first converts .java file into .class file by using Compiler (.class is nothing but byte code file.) and Interpreter reads byte codes.

How can I swap two variables without using a third variable?

Add two variables and assign the value into First variable. Subtract the Second value with the result Value. and assign to Second variable. Subtract the Result of First Variable With Result of Second Variable and Assign to First Variable. Example:

int a=5,b=10;a=a+b; b=a-b; a=a-b;

An other approach to the same question

You use an XOR swap.

for example:

int a = 5; int b = 10;
a = a ^ b;
b = a ^ b;
a = a ^ b;

What is data encapsulation?

Encapsulation may be used by creating ‘get’ and ’set’ methods in a class (JAVABEAN) which are used to access the fields of the object. Typically the fields are made private while the get and set methods are public. Encapsulation can be used to validate the data that is to be stored, to do calculations on data that is stored in a field or fields, or for use in introspection (often the case when using javabeans in Struts, for instance). Wrapping of data and function into a single unit is called as data encapsulation. Encapsulation is nothing but wrapping up the data and associated methods into a single unit in such a way that data can be accessed with the help of associated methods. Encapsulation provides data security. It is nothing but data hiding.

What is reflection API? How are they implemented?

Reflection is the process of introspecting the features and state of a class at runtime and dynamically manipulate at run time. This is supported using Reflection API with built-in classes like Class, Method, Fields, Constructors etc. Example: Using Java Reflection API we can get the class name, by using the getName method.

Does JVM maintain a cache by itself? Does the JVM allocate objects in heap? Is this the OS heap or the heap maintained by the JVM? Why

Yes, the JVM maintains a cache by itself. It creates the Objects on the HEAP, but references to those objects are on the STACK.

What is phantom memory?

Phantom memory is false memory. Memory that does not exist in reality.

Can a method be static and synchronized?

A static method can be synchronized. If you do so, the JVM will obtain a lock on the java.lang.
Class instance associated with the object. It is similar to saying:

synchronized(XYZ.class) {

}

What is difference between String and StringTokenizer?

A StringTokenizer is utility class used to break up string.

Example:

StringTokenizer st = new StringTokenizer(”Hello World”);

while (st.hasMoreTokens()) {

System.out.println(st.nextToken());

}

Output:

Hello

World

Java And Internet

Java And Internet

Java And Internet


Why java is important to the Internet

The Internet helped catapult java to the forefront of programming, and java, in turn, has had a profound effect on the Internet. The reason for this is quite simple: Java expands the universe of objects that can move about freely in cyberspace. In a network, two very broad categories of objects are transmitted between the server and your personal computer: passive information and dynamic, active programs. For example, when you read your e-mail, you are viewing passive data. Even when you download a program, the program’s code is still only passive data. Even when you download a second type of object can be transmitted to your computer: a dynamic, self-executing program. Such a program is and the server yet initiates active agent on the client computer. For example, the server to display properly the data that the server is sending might provide a program.

As desirable as dynamic, networked programs are, they also present serious problems in the areas of security and portability. Prior to java, cyberspace was effectively closed to half the entities that now live there, as you will see, java addresses those concerns and, by doing so, has opened the door to an exciting new form of program: the applet.

Java Applets and Applications

Java can be used to create two types of programs: applications and applets. An application is a program that runs on your computer, under the operating system of that computer. That is , an application created by java is more or less like one created using C or C++. When used to create applications, java is a not much different from any other computer language. Rather, it is java’s ability to create applets that makes it important. An applet is an application designed to be transmitted over the Internet and executed by a java-compatible Web browser. An applet is actually a tiny java program, dynamically downloaded across the network, just like an image, sound file, or video clip. The important difference is that an applet is an intelligent program, not just and animation or media file. In other words, and applet is a program that can react to user input and dynamically change not just run the same animation or sound over and over.

Security

As you are likely aware, every time that you download a “normal ” program, you are risking a viral infection. Prior to java, most users did not download executable programs frequently, and those who did scanned them for viruses prior to execution. Even so, most users still worried about the possibility of infection their systems with a virus. In addition to viruses, another type of maillicious program exists that must be guarded against. This type of program can gather private information, such as credit card numbers, bank account balances, and passwords, by searching the contents of your computer’s local file system, java answer both of these concerns by providing a “firewall” between a networked application and your computer.

Portability

Many types of computers and operating systems are in use throughout the world - and many are connected to the Internet. For programs to be dynamically downloaded to all the various types of platforms connected to the Internet, some means of generating portable executable code is needed. As you will soon see, the same mechanism that helps ensure security also helps create portability. Indeed, java’s solution to these two problems is both elegant and efficient.

Friday, August 13, 2010

Java Platform, Enterprise Edition


Java Platform, Enterprise Edition (Java EE) 6 is the industry standard for enterprise Java computing. Utilize the new, lightweight Java EE 6 Web Profile to create next-generation web applications, and the full power of the Java EE 6 platform for enterprise applications. Developers will benefit from productivity improvements with more annotations, more POJOs, simplified packaging, and less XML configuration.

Thursday, August 12, 2010

Computer Education: Programming In C++

Computer Education: Programming In C++: "Probably the best way to start learning a programming language is by writing a program. Therefore, here is our first program: // my fir..."

Computer Education: Importance Of Java Programming

Computer Education: Importance Of Java Programming: "Java is a programming language distinct from the markup scheme for defining hypertext, the Hypertext Markup Language (HTML). Java doesn..."

Importance Of Java Programming


Java is a programming language distinct from the markup scheme for defining hypertext, the Hypertext Markup Language (HTML). Java doesn't compete with or replace HTML, nor does it negate the work done creating content using HTML for the Web.

When it was released in the spring of 1995 by Sun Microsystems, Java unleashed a level of interactivity on the Web that had never been possible before. Java makes the Web interactive.

Java connects with HTML and the Web through a special HTML element called APPLET, which allows developers to include Java programs called applets on Web pages. These applets are essentially software programs that the user's browser downloads (automatically, as part of Web page observation) and executes. With real-time graphical input and output possible through the applet on the page, Java thus opens windows to into richer levels of interactivity and visualization.

What is the Big Deal About Java?

Prior to 1995, people and organizations had been using webs of hypermedia on the World Wide Web to communicate globally and instantly. But something was missing. The often intriguing, informative, and useful Web content was devoid of much interactivity. Some users felt that the hyperlinks on the Web just kept leading them on, until ultimately, the Web seemed like a road to nowhere: with no there there. Java potentially changes this.

Java enables developers to create content that can be delivered to and run by users on their computers. This content is in the form of software that can support anything that programmers can dream up: spreadsheets, tutorials, animations, and interactive games. With the Web page as the delivery platform, this software can support a variety of information tasks with true interactivity: for example, users can get continuous, instantaneous feedback for applications in visualization, animation and computation. Users of the Web in Java age may indeed find a there on the Web: a place to play, work, or learn.

Who is Using Java?

Many companies have made a decision to use Java as the language for their software development. As the first interactive language for the Web content, Java got a good head-start, resulting in a good base of experience and skills among programmers. With Sun Microsystems' committment to Java, it looks like Java is a good choice for Internet content development.

My Opinion of Java

I was very excited about Java when it was released in the spring of 1995. I spent the summer of 1995 writing the first published Java book and, in it, I was enthusiastic with my first experience of Java. I saw so much potential.

Yet today, I see results with Java that are far, far less than what I had imagined. More than two years from its invention (two years is aeons in Internet time), Java really isn't used as extensively as I thought it would be. I think the reasons for this lie not in the language--it is actually a very good language. Instead, I think these issues have held Java back:

  1. Web developer's attention was scattered during the period 1995-1996 with many new technologies (Shockwave, JavaScript [JavaScript has nothing to do with Java], ActiveX) that all seemed to promise a richer and more interactive Web. The tragedy of the JavaScript name, for example, lulled (and still lulls) many Web developers to squander their skills on buggy, non-standard, JavaScript code on HTML pages.
  2. Many Web developer's lack the skills to create useful interactivity in Web pages. Java is a software language--it is not something that a person can pick up as easily as HTML. Java requires a solid understanding of object-oriented development methodologies and implementation practices, besides good software engineering skills. And since Java is used to create interactivity on Web pages, developers need to know about human-computer interface design. And since Java can be used to mediated human communication (in groupware, for example), developers should understanding computer-mediated communication issues. What this means is that someone who wants to do serious Java development should be a specialist. Amateur users can learn Java in 14 days and create "toy" applets, but the level of their work would be far below the power and potential of Java itself. My feeling is that it is a tragedy that few people realize this distinction and instead dink around with silly animations and toy applets on their pages and believe they are creating "interactive content."
  3. Java class libraries are just coming into existence. The raw Java Developer's Toolkit that Sun provides for free shouldn't be the basis for serious Java development--this is like starting to build a car using molten metal, plastic, and glass to create the screws, parts, and mechanisms that will make up the components. Instead, Java developers need to stand on the shoulders of giants and start building serious, complex applications using components and subsystems, not raw materials.

I think in the long run, Java is a good choice for development. I think the advances in Java compilation and run-time support in the latest versions of Web browsers should support a more pleasing experience for users of Java applets. I think that, in several years, developers may eventually grasp the importance of Java as a bridge of human communication online. I think then we'll begin to see the potential of Java.

Tuesday, August 10, 2010

Java Script Language


Overview

This document is an introduction to the JavaScript Programming Language for professional programmers. It is a small language, so if you are familiar with other languages, then this won't be too demanding.

JavaScript is not Java. They are two very different languages. JavaScript is not a subset of Java. It is not interpreted Java. (Java is interpreted Java!) JavaScript shares C-family syntax with Java, but at a deeper level it shows greater similarity to the languages Scheme and Self. It is a small language, but it is also a suprisingly powerful and expressive language.You should take a look at it. You will find that it is not a toy language, but a full programming language with many distinctive properties.

JavaScript is a regular language which won't take much time to learn. It is better suited to some tasks, such as client programming, than Java is. In my own practice, I have found that working with JavaScript has made me a better Java programmer because it introduced me to a useful set of dynamic techniques.

When JavaScript was first introduced, I dismissed it as being not worth my attention. Much later, I took another look at it and discovered that hidden in the browser was an excellent programming language. My initial attitudes were based on the initial positioning of JavaScript by Sun and Netscape. They made many misstatements about JavaScript in order to avoid positioning JavaScript as a competitor to Java. Those misstatements continue to echo in the scores of badly written JavaScript books aimed at the dummies and amateurs market.

History

JavaScript was developed by Brendan Eich at Netscape as the in-page scripting language for Navigator 2. It is a remarkably expressive dynamic programming language. Because of its linkage to web browsers, it instantly became massively popular. It never got a trial period in which it could be corrected and polished based on actual use. The language is powerful and flawed.

This document describes ECMAScript Edition 3 (aka JavaScript 1.5). Microsoft and Netscape are developing a static revision which does not correct the language's flaws. That new language is not JavaScript and is beyond the scope of this document.

JavaScript is THE scripting language of the Web.

JavaScript is used in millions of Web pages to add functionality, validate forms, detect browsers, and much more.







Java Applet Programming


History

  • It was originally called Oak, developed by SUN Microsystems, in a project called FirstPerson for smart appliances, such as set-top-box (interactive TV) 1992, lead by James Gosling.
  • It adopted C++ syntax but get rid of pointer, memory management, and multiple inheritance, which are main causes of programming errors.
  • It failed to be adopted by Timer Warner in Spring 93's ITV trial.
  • 1993 Marc Andreesen developed Mosaic Web Browser, started the web revolution.
  • Oak found its reason for existence. A Web browser called WebRunner was developed for demonstration.
  • January 1995, Sun adopted Java name due to trademark issue.
  • Marc Andreesen saw the demo and license it for use in its browser.
  • Nov. 1995, 1st Beta release with developer kit and source code.

What is Java Applet

  • Java is a general purpose programming language.
  • A Java program is created as a text file with .java extension.
  • It is compiled into one or more files of bytecodes with .class extension.
  • Bytecodes are a set of instructions similar to machine code of a specific machine but it can be run on any machine that has a Java Virtual Machine (JVM). JVM interprets bytecodes.
  • JVM was first implemented on Sparc/Solaris and PC/Win32. Now ported to many other platforms.
  • Java applets are Java programs that are retrieved and executed by web browsers through the JVM under tight secure environment.
  • Web browsers retrieve Java applets according to following tags in the web pages:

  • deprecated or the new more general,

    height=500>

  • are used to specify parameters for the applet. For example,
    -- the height (in pixels) of the tallest frame
    -- the directory that has the animation frames (gif, jpg)
  • All other types of java programs are called Java applications.
  • Examples:
  • Network Restoration Applet: User specifies two end node of a failed link. The applet retrieves the simulation results of two network restoration algorithms (twoprong and rreact) in two corresponding files at original web server site, and plot the results.
  • SUN Java demos:
    • MoleculeViewer
    • SimpleGraph
    • SortDemo
    • BarChart
    • Animator
    • JumpingBo