From which class Password inherits from which classes in java?
Password inherits from which one of the following classes?
Write a Java program to count 1 to 1000 numbers using 10 threads?
// need a class to do customized counting
// (this can be a local class)
final class CounterThread extends Thread {
}
public void run() {
// actual counting process
for (int i = rangeStart; i <= rangeEnd; ++i) {
count += nums[i];
}
}
}
// define the number of ints we want to add up
final int ARRAY_SIZE = 1000;
// define the number of threads to use
final int NUM_THREADS = 10;
// define the number of ints each thread will add
final int NUMS_PER_ARRAY = ARRAY_SIZE / NUM_THREADS;
// NOTE: if ARRAY_SIZE is not evenly divisible by NUM_THREADS, then the
// code will need some tweaking to get the correct answer
int[] nums = new int[ARRAY_SIZE]; // assuming this is filled with numbers to count
// create our array of worker threads
CounterThread[] threads = new CounterThread[NUM_THREADS];
for (int i = 0; i < threads.length; ++i) {
}
// wait for all threads to finish
for (int i = 0; i < threads.length; ++i) {
}
// add up the individual counts from each thread
int totalCount = 0;
for (int i = 0; i < threads.length; ++i) {
}
System.out.println(totalCount);
Write a program to print all the ASCII values and their equivalent characters using a while loop?
#include<stdio.h>
#include<conio.h>
void main()
{
int a=1;
while(a<=255)
{
printf("%d=%c",a,a );
a++;
}
getch();
}
I don't know how it is done in Windows, but in Linux based systems you can remove Java using the "apt-get remove" command.
Java itself is 100% safe to have installed on your computer. Programs written in Java, however, may still harm your computer. Always look for user reviews before running ANY unknown program on your computer.
Is overloading done at compile time or run time?
Overloading will be done at compile time itself.
Proof: If you try to narrow down the access modifier for a method from public in the parent class to private in the child class while overloading, the compiler will not let you do it.
What is vector and array processing?
An important part of IDL is the ability to work with data that is organized as vectors and arrays. We will first describe vectors and arrays and then show some tools for constructing them. Finally, we will demonstrate some of their uses. In addition to arrays of numbers, which we will describe here, there are also arrays of strings, structures and objects. You can look up information about them in IDL help if you are eager to find out about them now.
Arrays are especially important in signal image processing. We will find that images are just arrays of values with one value for each pixel. Vectors are important in the representation of one-dimensional functions such as functions of time or one spatial dimension.
Vectors
A vector is a list of data items, and can be constructed with an assignment statement like
A=[1.2, 3.1, 4.6, 5.7]
Note that square brackets are used to contain the list. Try typing a list like that shown above and then using HELP,A to get information about the vector.
Vectors can contain any of the number types that are accepted by IDL. When the assignment is made all of the numbers are converted to one type. The type that is used is determined by the data type hierarchy. Try typing
A=[1, 3B, 4L, 5.7] & HELP,A
IDL responds that A is an array of type FLOAT of length 4. If you were to type
A=[1, 3B, 4L, 5] & HELP,A
you would find that A is now of type LONG. The rule is to convert all of the numbers to the highest number type.
Arrays
We can think of a vector as a list that has one dimension. It is a row of data. An array is a list that is arranged in multiple dimensions. A two-dimensional array is a vector of vectors that are all of the same length.
C=[[1,2,3,4],[5,6,7,8],[7,6,5,4]] & PRINT,C
1 2 3 4
5 6 7 8
7 6 5 4
We see that A has three rows and four columns and that each row is one of the vectors in the list. An array can contain any of the IDL data types. When it is created all of the numbers are converted to the highest number type. We will describe a number of IDL functions for the construction of arrays. By using these functions one can construct arrays of up to eight dimensions.
Indexing
Column and Row Index
It is important to be able to refer to particular elements of an array. An element in column 1 and row 2 can be referred to by C[1,2]. In the above array we would find that C[1,2]=6. In IDL the column index comes before the row index.
Rows and columns are indexed beginning with the number 0. The column indexes of C are 0, 1, 2, 3 and the row indexes are 0, 1, 2. Zero-referenced indexing is a convention that may seem strange at first, but it has programming advantages.
One can refer to an entire row by using an asterisk in the column position. C[*,r] refers to the vector in row r. Try the command PRINT,C[*,2].
One can refer to an entire column by using an asterisk in the row position. C[col,*] refers to the vector in column col. Try the command PRINT,C[3,*].
A part of a row or column can be indexed by providing a list of the elements that are wanted. Try the following
row =[0,1,2] & col = [3,2,1] & PRINT,C[col,row]
Can you explain what is printed?
A contiguous segment of column or row elements can be referred to with the notation a:b. For example, C[0:2,2] refers to the elements in positions 0,1,2 in row 2. Try the command PRINT,C[0:2,2]
Array Index
Every element in an array has an array index. The array index is found by counting each element from the beginning of the array to the end row by row. An array that has four columns and three rows would have the indexes as shown below.
0 1 2 3
4 5 6 7
8 9 10 11
Any element in the array can be referred to by its array index. A list of elements in positions 0, 6 and 8 can be printed by
k=[0,6,8] & C[k]
One can find the value of array index from the row and column indexes. The number of columns, n, has to be known. Then k is simply
k = col + row*n
If k is given then the column and row indexes can be found by integer operations:
row = k/n
col = k - row*n
For an array with n=4 columns, C[6]=C[2,1]. You should try converting in both directions.
Array Creation Tools
IDL provides a number of functions that can be used to create arrays and initialize their values. The list can be found in the section "Array Creation Routines" in IDL Online Help. A subset of these routines are listed below.
BINDGEN Return a byte array with each element set to its subscript.
BYTARRCreate a byte vector or array.
FINDGEN Return a floating-point array with each element set to its subscript.
FLTARRReturn a floating-point vector or array.
INDGEN Return an integer array with each element set to its subscript.
INTARRReturn an integer vector or array.
LINDGEN Return a longword integer array with each element set to its subscript.
LONARRReturn a longword integer vector or array.
IDENTITY Return an identity array.
MAKE_ARRAYGeneral purpose array creation.
REPLICATEForm array of given dimensions filled with a value.
The functions BYTARR, FLTARR, INTARR, LONARR create arrays with of the type indicated by the first letter of the name and with their initial values set to zero. You can then enter data into them by assignment statements. For example, create an integer array of size 3x4 and set the elements of the first row to the value 3.
A=INDGEN(3,4)
A[*,0]=3
PRINT,A
The functions BINDGEN, INDGEN, FINDGEN, LINDGEN create arrays of the type indicated by the first letter of the name and with the initial values set to the array index. For example, create an array of type byte of size 3x4 and set its initial value to the index.
B=BINDGEN(3,4)
PRINT,B
0 1 2
3 4 5
6 7 8
9 10 11
The functions that generate index arrays are very useful in creating a vector of independent variables to be used in calculating and plotting a function. Suppose that you needed to plot the function (1+t2)Cos(5t) over the interval [0,3] in steps of size 0.01. You will then need a vector of 301 values t=[0, .01, .02, ..., 2.99, 3]. You certainly would not want to type all this in. The statements that will do the calculation and plot a graph are given below.
t=FINDGEN(301)/100 ;Generates the desired vector
f=(1+t^2)*cos(5*t) ;Calculates the function
plot,t,f ;Draws the graph
The IDENTITY function returns a square array of type float with the elements on the main diagonal set to 1 and all others set to zero. This function is very useful in many linear algebra computations.
I=IDENTITY(4)
PRINT,I
The REPLICATE function makes an array of the specified size in which a give value placed in all of the positions. To make a 5x2 array in which all of the elements contain the value 3.1 one can use
C=REPLICATE(3.1,5,2)
PRINT,C
The function MAKE_ARRAY is the most general array creation tool. It has many options which are best described by the online help documentation and the reference manual.
Deploy = build packet application that use by user to install your program
Deploy = Finishing & Packaging
In Java :
- desktop : usually we deploy application to *.jar files
- web app : usually we deploy it to *.war files
feel free to visit http://www.javaclopedia.com
What is the least possible number of iterations for a for loop?
The least possible is no iterations:
for (x=0; x<max; ++x) {
// ...
}
In the above example, if max is less than or equal to zero then the body of the loop will not execute.
Explain three different methods in java?
How do you overload constructors in java?
Overloading a constructor means typing in multiple versions of the constructor, each having a different argument list, like the following examples:
class Car {
Car() { }
Car(String s) { }
}
The preceding Car class has two overloaded constructors, one that takes a string, and one with no arguments. Because there's no code in the no-arg version, it's actually identical to the default constructor the compiler supplies, but remember-since there's already a constructor in this class (the one that takes a string), the compiler won't supply a default constructor. If you want a no-arg constructor to overload the with-args version you already have, you're going to have to type it yourself, just as in the Car example.
Overloading a constructor is typically used to provide alternate ways for clients to instantiate objects of your class. For example, if a client knows the Car name, they can pass that to a Car constructor that takes a string. But if they don't know the name, the client can call the no-arg constructor and that constructor can supply a default name
What is the meaning of and in C programming language and when is it used?
logical and: exp1 && exp2 means:
exp1==0 ? 0 : exp2==0 ? 0 : 1
Can you define multiple parameters for one method in java?
The formal Java Language Specification does not list a hard limit on the number of formal parameters allowed. Generally, if you're worried that you might "run out" of parameter spaces, you will probably want to redesign your method.
You must have the Java Run-time Environment installed on your computer.
Steps:
1. Open Command Prompt
2. Enter the command: javac class.java
3. Enter the command: java <classfilename> (without the .java or .class extension)
The javac command will compile your java source file and create a class file. The java command will execute or run your java class file.
Why use static variable in programming language?
For C programming, the use of a static variable has two uses:
One reason is to hide the variable from other modules. The scope of the static variable is limited to the compilation unit that it is described in.
The second use of a static variable is to keep the value of the variable intact through the entire program execution unit.
What are the problems of the bottom-up budgeting approach?
The problem related with this technique are as follow: To many people emplyeed in the decision making process causing long term planning before an agreement is reached. Sometimes the influencer maker in the belonging group might furhter emphasize his opinion towars a strategic which it is not very wise. The problem related with this technique are as follow: To many people emplyeed in the decision making process causing long term planning before an agreement is reached. Sometimes the influencer maker in the belonging group might furhter emphasize his opinion towars a strategic which it is not very wise.
Specification forms of inheritance in java?
single level inheritance eg ( class B extends Class A)
Multilevel inheritance eg( class C extends class B and class B extends class A)
multiple inheritance Class C inherits Class A features as well as Class B featues.This type of inheritance is not allowed in JAVA.
What are the rules of creating identifier?
Identifiers refers to the names of variables, functions and array. These are user defined names and consist of a sequence of letters and digits, with a letters as a first character.Both uppercase and lowercase letters are permitted, although lowercase letters are commonly used. The underscore character is also permitted in identifiers. It is usually used as a link between two words in long identifiers.
In C, identifiers may contain any alphanumeric characters (a-z, A-Z, 0-9) as well as underscores (_), but must not begin with a number.
Can I have some example java programs?
import java.io.*;//package defined
//class name example
public class example{
//function name declare
public static void main(String str)
{
system.out.println("welcome to java world");
}
}
to run this program :-
1.setting the environmental variables
(including path c:/jdk1.3/bin/ in existing path)
not as like that what ever the path of bin you mention,specify correctly
2.in the command prompt
type javac
it display some thing
with out any error
3.
in the command prompt
>/javac example.java
4.
>/java example
What is the difference between software and interface?
software is a collection of programs
inteface is a accessing a application
How do you achieve encapsulation by using class?
By making fields private. That way, they can't be directly accessed from the outside - the are hidden, that is, encapsulated.
How do you invoke static methods?
if some method is static, then you can not call that method through the oobject of that class. but the name of the class.
let us see a example:
class Test
{
int a;
int b;
static void show()
{
System.out.println("we are in show");
}
}
class Main
{
public static void main(String args[])
{
Test t=new Test();
t.show();\\thiss is an erroraneous code. because, the method "show()" is static.
Test.show();\\this is correct
}
Arnas Sinha
What time of loop is used when you know how many times the loop instructions should be processed?
It's best to use a for loop.
For example, if you want 10 iterations:
for (int i = 1; i <= 10; i++)
{
// Any commands you write here will repeat 10 times.
}
What is the best site to download java games?
One can find a free collection of Java games from Mob or Java's website. There are some other websites that host Java games, such as Funny-Games and Chess Games.