answersLogoWhite

0

📱

Java Programming

The Java programming language was released in 1995 as a core component of the Java platform of Sun Microsystems. It is a general-purpose, class-based, object-oriented language that is widely used in application software and web applications.

5,203 Questions

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.

Can a class extend exception?

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.

Write buzzwords in java?

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.

Similarities and differences of multitasking and multithreading?

Both terms are used to describe a computer process known as multi-tasking, where a single CPU core switches between tasks periodically to reduce inefficiency and wasted time, and to allow the user to perform multiple tasks at the same time. The difference between the two are technical distinctions, rather than a difference in their intended effect.


Multiprogramming was the first form of multi-tasking, and introduced in the the concept of yielding. When an instruction could not be completed immediately (such as when reading from a disk or other slowperipheral, the current task was set aside, and another task would run until the data from the paused task was ready.


Some time later, time sharing was introduced to allow more fine-grained control over the yielding process. The first form was known as cooperative time sharing. In this model, a program would run for a while and then willingly relinquish control so that another process could have a chance. This was referred to as cooperative time sharing. This model had some drawbacks, as programs could be written incorrectly and fail to yield in a timely manner, causing the system to become slow and unresponsive. Additionally, programs cooperated in the same unprotected memory space, so a crash of one program meant that the entire system could be brought down by a single fault.


Advances in hardware allowed for the processes to be interrupted by the operating system. This brought about the next generation of time sharing, known as preemptive time sharing. Along with this model came advances in virtual memory that allowed each program to run in its own virtual memory space. No longer would a single program cause a systemic crash, and a program could no longer fail to yield (in theory, at least).

What is java compound statement?

A compound statement is a group of statements enclosed in braces, i.e curly brackets. A compound statement is a group of statements enclosed in braces, i.e curly brackets.

What is a finite and infinite set?

A set which containing $and pi are the end blocks are the finite and without these are infinite

What is the difference between exe and class files?

in .exe file it contains

machine understandable code. but in .class file it contain only byte code which is not understadable by the microprocessor it will understud by the jvm only . we con't execute .class file without jvm . but we can execute .exe file without c-compiler .