What is the difference between abstract class and static class?
An ADT is simply a base class that has one or more pure-virtual methods. A pure-virtual method is similar to a virtual method except that the ADT need not provide any implementation for that method. Even if it does provide a generic implementation, all derivatives must override that method, even if only to call the generic base class method. This ensures that all derivatives provide their own specialised implementations. A derivative that does not provide an implementation for all the pure-virtual methods it inherits becomes an ADT itself. However any implementations that it does provide can subsequently be inherited by its derivatives (those methods effectively become virtual methods rather than a pure-virtual method). Only classes that provide or inherit a complete implementation of all pure-virtual methods can physically be instantiated.
Going back to our shape class, the shape::draw() method is an ideal candidate for a pure-virtual function since it is impossible to draw a shape without knowing what type of shape it is. However, a circle class would be expected to know how to draw itself thus it can provide the specific implementation for drawing circles. Similarly, rectangles and triangles will provide their own specific implementations. This then makes it possible to store a collection of generic shapes and have them draw themselves without the need to know their actual type; as with all virtual methods, the derivatives behave according to their actual type.
Note that static classes have no need for any constructors, operators or destructors (they have no this pointer since there can never be any instances of the class), thus the compiler-generated default constructor, copy constructor, destructor and assignment operator must all be declared private. Some languages may do this automatically but in C++ (which has no concept of static classes) you must explicitly declare them as such.
While static classes do have their uses, bear in mind that the point of having a class in the first place is in order to instantiate independent objects from the class. Thus the only time you should ever use a static class is when the class data members must exist for the entire duration of the program and you want to ensure there can only ever be one instance of those members. However, for memory efficiency alone, a singleton class would be the preferred method. Moreover, if some or all of the static methods are closely associated with a generic class, then it makes more sense to encapsulate those methods as static members of that generic class rather than as a completely separate static class.
Explain the various data types available in SQL?
You retrieve, store, and update SQL3 datatypes the same way you do other datatypes. You use either ResultSet. getXXX or CallableStatement. getXXX methods to retrieve them, PreparedStatement. setXXX methods to store them, and updateXXX to update them. Probably 90 percent of the operations performed on SQL3 types involve using the getXXX , setXXX , and updateXXX methods. The following table shows which methods to use:
SQL3 type
getXXX method
setXXX method
updateXXX methodBLOB
getBlob
setBlob
updateBlobCLOB
getClob
setClob
updateClobARRAY
getArray
setArray
updateArrayStructured type
getObject
setObject
updateObjectREF (structured type)
getRef
setRef
updateRef
For example, the following code fragment retrieves an SQL ARRAY value. For this example, the column SCORES in the table STUDENTS contains values of type ARRAY . The variable stmt is a Statement object. ResultSet rs = stmt.executeQuery( "SELECT SCORES FROM STUDENTS WHERE ID = 2238"); rs.next(); Array scores = rs.getArray("SCORES");
The variable scores is a logical pointer to the SQL ARRAY object stored in the table STUDENTS in the row for student 2238.
If you want to store a value in the database, you use the appropriate setXXX method. For example, the following code fragment, in which rs is a ResultSet object, stores a Clob object: Clob notes = rs.getClob("NOTES"); PreparedStatement pstmt = con.prepareStatement( "UPDATE MARKETS SET COMMENTS = ? WHERE SALES < 1000000", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); pstmt.setClob(1, notes);
This code sets notes as the first parameter in the update statement being sent to the database. The CLOB value designated by notes will be stored in the table MARKETS in column COMMENTS in every row where the value in the column SALES is less than one million
1.emphasis is on data rather than procedure
2.programs are divided into what are known as objects.
3.data structure are designed such that they charatersize the object.
4.data is hidden and cannot be accessed by external functions.
5.it follows bottom-up approach in program design
Why Java is called object oriented programming language?
Java is an object-oriented computer programming language that is used for application as well as system software development. It is best for web based applications such as servlets, XML design...etc., i.e. the applications that can run on the Internet. It can be used as front end tool for the back end database application. for example, the famous Oracle Database management system was designed using Java technology. It is also platform independent. meaning it can run under most platforms and OSs. Java technology was created as a computer programming tool in a small, secret effort called "the Green Project" at Sun Microsystems in 1991.
The secret "Green Team," fully staffed at 13 people and led by James Gosling, locked themselves away in an anonymous office on Sand Hill Road in Menlo Park, cut off all regular communications with Sun, and worked around the clock for 18 months.
They were trying to anticipate and plan for the "next wave" in computing. Their initial conclusion was that at least one significant trend would be the convergence of digitally controlled consumer devices and computers.
A device-independent programming language code-named "Oak" was the result.
To demonstrate how this new language could power the future of digital devices, the Green Team developed an interactive, handheld home-entertainment device controller targeted at the digital cable television industry. But the idea was too far ahead of its time, and the digital cable television industry wasn't ready for the leap forward that Java technology offered them.
As it turns out, the Internet was ready for Java technology, and just in time for its initial public introduction in 1995, the team was able to announce that the Netscape Navigator Internet browser would incorporate Java technology.
Now, nearing its twelfth year, the Java platform has attracted over 5 million software developers, worldwide use in every major industry segment, and a presence in a wide range of devices, computers, and networks of any programming technology.
In fact, its versatility, efficiency, platform portability, and security have made it the ideal technology for network computing, so that today, Java powers more than 4.5 billion devices: * over 800 million PCs * over 1.5 billion mobile phones and other handheld devices (source: Ovum) * 2.2 billion smart cards * plus set-top boxes, printers, web cams, games, car navigation systems, lottery terminals, medical devices, parking payment stations, etc. Today, you can find Java technology in networks and devices that range from the Internet and scientific supercomputers to laptops and cell phones, from Wall Street market simulators to home game players and credit cards -- just about everywhere.
The best way to preview these applications is to explore java.com, the ultimate marketplace, showcase, and central information resource for businesses, consumers, and software developers who use Java technology.
Why Software Developers Choose Java Technology
The Java programming language has been thoroughly refined, extended, tested, and proven by an active community of over five million software developers.
Mature, extremely robust, and surprisingly versatile Java technology has become invaluable in allowing developers to: * Write software on one platform and run it on practically any other platform * Create programs to run within a web browser and web services * Develop server-side applications for online forums, stores, polls, HTML forms processing, and more * Combine Java technology-based applications or services to create highly customized applications or services * Write powerful and efficient applications for mobile phones, remote processors, low-cost consumer products, and practically any device with a digital heartbeat
Primary and secondary key in DBMS?
key is nothing but a attribute and attribute is the aspect of a member in an entity
entity is represented by set of attributes.
primary key is the one which is selected by the database designer to identify a entity in a entity set
super key is one or more attributes which is used to identify the entity in an entity set uniquely
candidate key minimal number of super keys... in some context super key and secondary key are equal.
foreign key is the relational constraint between tables or entities
A secondary key is made on a field that you would like to be indexed for faster searches!
For any Further detail,you visit this website:http://www.iyogibusiness.com
What is mean by instance variable with example?
hi friend....
Instance variable means with which you need to create an obeject in order to invoke any methods or variables defined in a class.
For ex:
class A
{
int a=10;
public void inc()
{return a++; }
}
To invoke a member
A b=new A();
b.inc();
System.out.println(b.a);
If incase of a static method you can directly call using class name itself.
like :
b=Math.sqrt(a);
How do you link a programming with other programming languages?
This is done via a call sequence. The syntax is different between languages but the process is about the same. The calling program issues a call to the called program and passes data items known as arguments. These arguments are used to instruct the called program on what actually to do. After the called program has completed its function it passes these arguments back to the calling program along with a return code to inform the calling program everything was ok, or not ok.
Yes You can. The features of such a class would be similar to what an Exception would have but not exactly as a predefined Java Exception.
When you create a user defined exception you extend the java.lang.Exception class which in turn extends the java.lang.Throwable so indirectly you are extending the Throwable class while creating a user defined exception...
What is difference between static remote method invocation and dynamic remote method invocation?
Typical way for writing code that uses RMI is similar
to the process for writing RPC
❍ declare the interface in IDL, compile the IDL file to generate
client and server stubs, link them with client and server side
code to generate the client and the server executables
❍ referred to as static invocation
❍ requires the object interface to be known when the client is
being developed
❒ Dynamic invocation
❍ the method invocation is composed at run-time
invoke(object, method, input_parameters, output_parameters)
❍ useful for applications where object interfaces are
discovered at run-time, e.g. object browser, batch processing
systems for object invocations, "agents"
How to write Short Java program to sort a sequence of numbers 2345 12 1 111 in ascending order?
Do you mean how do you write a Java program to print out those numbers in ascending order? Because you have specified thosenumbers, I can only assume that the following will suffice:-
public int main( String[] args )
{
System.out.println( "0.235 4.62 7.25 7.89 23.5" );
}
If you want to know how to sort a general array into ascending order, try Google for sorting algorithms, such as "bubble sort", "insertion sort", "heap sort", "quick sort" etc.
Using for loop write a java program to print the table of a given number on the screen?
class Table
{
int n;
void func(int n)
{
int k=2;
for(int i=1;i<n;i++)
{
System.out.println("table of "+k);
for(int j=1;j<=10;j++)
{
int a=j*k;
System.out.print(" "+a);
System.out.print(" ");
}
k=k+1;
System.out.print("\n");
}
}
public static void main(String k[])
{
Table t =new Table();
int num=Integer.parseInt(k[0]);//pass the number upto you want the tables eg:4
t.func(num);
}
}
Multiplication table using do while loop?
#include
void main()
{
int i=2,m,n;
printf("enter number");
scanf("%d",&n);
do
{
m=i*n;
printf("%d*%d=%d\n",n,i,m);
i=i+1;
}
while (i<=10);
}
What is the function of keywords in the C language?
Keywords are reserved words in a programming language whose meaning are available in the respective compiler. C programming language has the following keywords; default, return, struct, void, volatile, unsigned, signed, double, while, union, static, switch, typedef, register, short, size of, for, long, if, int, goto, enum, float, else, extern, do, const, break, char, case, break and auto.
How do you call a method from another class in Java?
If the method is static you can do this way:
Classname.method()
If the method is not static then you would have to instantiate the class that contains this method and then call it using that object.
Classname obj = new Classname();
obj.method()
Files containing Java code must end with what extension?
They end with an extension .java
Test.java would be a java source file.
The contents of Test.java could be
package xyz;
import java.util.*;
public class Test {
...
...
..
.
.
}
What is the use of new operator?
A new operater is used to allocating a memory space for a particular object.
buzzwords are nothing but the feature of java programming and they are as follows...
1 complied and interpreted
2 platform independent and portable
3 high performance
4 Robust
5 simple
6 Secure...........
Write a program that ask the user to enter a number n and display the first n even numbers?
#include "stdio.h" int main() { unsigned int number, count; printf("Enter the Number \t"); scanf("%d", &number); printf("The even numbers are: \n"); for(count = 0x01; (count < number && number!= 0x00)) { if(count%2) { }else { printf("%d\n", count); } count++; } return 0; }
What kind of data do you put in arrays?
You should use arrays when you have several pieces of related data, of the same type. As an example, let's suppose you have a series of measurements, for example, temperature measured every few minutes. It doesn't make sense (from a programming point of view) to use a different variable for every measurement, so you store the measurements as a group - as an array.
You should use arrays when you have several pieces of related data, of the same type. As an example, let's suppose you have a series of measurements, for example, temperature measured every few minutes. It doesn't make sense (from a programming point of view) to use a different variable for every measurement, so you store the measurements as a group - as an array.
You should use arrays when you have several pieces of related data, of the same type. As an example, let's suppose you have a series of measurements, for example, temperature measured every few minutes. It doesn't make sense (from a programming point of view) to use a different variable for every measurement, so you store the measurements as a group - as an array.
You should use arrays when you have several pieces of related data, of the same type. As an example, let's suppose you have a series of measurements, for example, temperature measured every few minutes. It doesn't make sense (from a programming point of view) to use a different variable for every measurement, so you store the measurements as a group - as an array.
What is use of string args in java?
If you're referring to "args" in the line: "public static void main(String args[])", then it is the name of the array that holds the command line arguments. So, if you called your java program (called myJavaProgram) from the command line using the following line:
java myJavaProgram Hello World "These are args"
Then args would have the following values stored in it:
args[0] = "Hello"
args[1] = "World"
args[2] = "These are args"
If you called your program from the command line like this:
java myJavaProgram Different Args
then args would contain
args[0] = "Different"
args[1] = "Args"
How do you create a File in Java?
There are a number of ways to create a file in java. The following example demonstrates a few:
import java.io.*;
import java.nio.charset.*;
public class Main {
public static void main(String[] args) {
try {
// Simplest way
PrintWriter out1 = new PrintWriter("file1.txt");
out1.println("hello file1!");
out1.close();
// Append to existing file if it already exists
PrintWriter out2 = new PrintWriter(new FileWriter("file2.txt", true));
out2.println("hello file2!");
out2.close();
// If non-default charset is needed
Charset charset = Charset.forName("UTF-16");
PrintWriter out3 = new PrintWriter(new OutputStreamWriter(new FileOutputStream("file3.txt"), charset));
out3.println("hello file3!");
out3.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Why is the JVM platform dependent?
That depends on how you look at it. The point of the JVM is to allow Java bytecode to be executed on any platform, regardless of what machine it was compiled on.
The actual implementation of the JVM, however, must be platform-specific.
When invoking a constructor from subclass its super class's no-arg constructor is always invoked?
Implicitly: (i.e., you do not code for it, but works as if you did)
calling the no-argument constructor of the subclass, and there is no explicitly "redirect" codes.
Explicitly:
a constructor with base() / super() in the implementation, even that invoked constructor required some arguments.
C# example: public SubClass(string whatever) : base() {//...}
Find diameter of the circle in java program?
public class CircleDiameter { publicCircleDiameter() { super(); } publicfloatgetDiameterFrmRadius(float radius){ return radius * 2; } /** * @param args */ public static void main(String[] args) { float radius = 5; CircleDiameter circle = newCircleDiameter(); float dia = circle.getDiameterFrmRadius(radius); System.out.println("Diameter of this circle is: " + dia); } }
What is difference between java applet and java Swing?
An applet is a Java program embedded in an HTTP document. When the HTTP document is loaded into a web browser, the Java program executes on the web. A widget = window gadget, a GUI (graphical user interface) control. A GUI control, such as a command button, is accessed by the user via a mouse click or by the keyboard. GUI programs can run on one's PC.