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

Explain different applications of Java programming language?

The Java programming language can be used to create many application. Some are:

1. Web based applications

2. Stand alone GUI based applications

3. Stand alone command window based applications

4. Games

5. Applets

etc...

Why we use IntegerParseInt in java?

Parsing is very important since the input from the user is not in the form of ints but in a String, therefore, you have to parse the String containing the number into a primitive data type.

i.e.

String num = "49";

int realNum = Integer.parseInt(num); // puts 49 into realNum;

What are loops in java?

A "null loop" is typically a loop which has no code in the loop body.

for(int i = 0; i < 57; ++i) {

}

How will you Write a c program to find the kth smallest element in an array in c?

//This is for kth largest element. (So this is for n-k smallest element) //Sudipta Kundu [Wipro Technologies] #include <stdio.h> //Input: array with index range [first, last)

//Output: new index of the pivot. An element in the middle is chosen to be a pivot. Then the array's elements are

//placed in such way that all elements <= pivot are to the left and all elements >= pivot are to the right.

int positionPivot(int* array, int first, int last); //Input: array with index range [first, last) and integer K (first <= K < last)

//Output: array whose Kth element (i.e. array[K]) has the "correct" position. More precisely,

//array[first ... K - 1] <= array[K] <= array[K + 1 ... last - 1]

void positionKthElement(int* array, int first, int last, int k); int main() {

int array[] = {7,1,8,3,1,9,4,8};

int i;

for (i = 0; i < 8; i++) {

positionKthElement(array, 0, sizeof(array) / sizeof(array[0]),i);

printf("%d is at position %d\n", array[i], i);

}

return 0;

}

int positionPivot(int* array, int first, int last) {

if (first last)

return first; int tmp = (first + last) / 2;

int pivot = array[tmp];

int movingUp = first + 1;

int movingDown = last - 1;

array[tmp] = array[first];

array[first] = pivot;

while (movingUp <= movingDown) {

while (movingUp <= movingDown && array[movingUp] < pivot)

++movingUp;

while (pivot < array[movingDown])

--movingDown;

if (movingUp <= movingDown) {

tmp = array[movingUp];

array[movingUp] = array[movingDown];

array[movingDown] = tmp;

++movingUp;

--movingDown;

}

}

array[first] = array[movingDown];

array[movingDown] = pivot;

return movingDown;

} void positionKthElement(int* array, int first, int last, int k) {

int index;

while ((index = positionPivot(array, first, last)) != k) {

if (k < index)

last = index;

else

first = index + 1;

}

}

Why is it necessary to use indentation and space in java statement?

The Java compiler doesn't need this, and in fact doesn't care. It is important to improve the readibility of the program for human programmers. Even with correct indentation, interpreting a computer program can be confusing. Without proper indentation and spacing, it will be much, much worse.

Implementation of stack using recursion?

public void reverse(Stack st)

{

int m = (int)st.Pop();

if (st.Count != 1)

reverse(st);

Push(st , m);

}

public void Push(Stack st , int a)

{

int m = (int)st.Pop();

if (st.Count != 0)

Push(st , a);

else

st.Push(a);

st.Push(m);

}

What is the use of overloading in java?

  • method overloading is the primary way polymorphism is implemented in Java
Overloading methods
  • overloaded methods:
    1. appear in the same class or a subclass
    2. have the same name but,
    3. have different parameter lists, and,
    4. can have different return types

What is the cold calling method?

cold calling approach is when someone calls on the phone trying to sell you thing but you tell them your not home

--------------

Cold Calling is a term used to refer to sales people who make unrequested approaches to individual to sell their product(s). This is outside a retail environment and is normally in the street or by phone. In some countrys this practice has been stopped because of the pressures placed on unsuspecting people to purchase items they have no real intention of purchasing

How do you compile java programming language?

Hello Frnd, As u say u want to Compile & Run Java Prog. for This if U have JAVA CREATOR then u can compile directly otherwise........ goto Start >run type "cmd" Press "Enter"after that goto C>java>bin> type for compile the prog. "javac PROG.NAME.java" Press "Enter" if Compile SuccessFully Type "java PROG.NAME" Press "Enter" For It This Is Must u save ur Prog. in the folder "bin" in java............. Hello Frnd, As u say u want to Compile & Run Java Prog. for This if U have JAVA CREATOR then u can compile directly otherwise........ goto Start >run type "cmd" Press "Enter"after that goto C>java>bin> type for compile the prog. "javac PROG.NAME.java" Press "Enter" if Compile SuccessFully Type "java PROG.NAME" Press "Enter" For It This Is Must u save ur Prog. in the folder "bin" in java.............

Java script is best than other language?

Javascript is useful for coding dynamic webpages. It allows you to make and interpret cookies, make simple animation, make pull down menus, and more. Javascript is used to add more power to HTML, which makes it very useful for webmasters to learn.

Examples of procedural programming language?

  1. ABC
  2. Ada
  3. Algol 60
  4. Algol 68
  5. APL
  6. Arc
  7. Assembly
  8. Awk
  9. BASIC
  10. Batch
  11. BCPL
  12. Befunge
  13. BETA
  14. C
  15. C++
  16. C--
  17. C# (pronounced C-sharp)
  18. CHILL
  19. Clipper
  20. Cobol
  21. CobolScript
  22. Component Pascal
  23. Cyclone
  24. D
  25. DATABUS
  26. Euphoria
  27. Forth
  28. Fortran
  29. Free Pascal
  30. GNU Pascal
  31. Icon
  32. IDL
  33. Jal
  34. JavaScript
  35. Jovial
  36. Lagoona
  37. Leda
  38. Limbo
  39. Lua
  40. m4
  41. Maple
  42. Mathematica
  43. MATLAB
  44. Modula-2
  45. Modula-3
  46. Mumps
  47. Oberon
  48. Objective Caml (OCaml)
  49. Occam
  50. Oz-Mozart
  51. Pascal
  52. Perl
  53. PHP
  54. PL
  55. PL/1
  56. Pliant
  57. PL/SQL
  58. PostScript
  59. PowerBuilder
  60. Proteus
  61. REBOL
  62. Rexx
  63. S-Lang
  64. Small C
  65. Snobol
  66. Tcl-Tk
  67. T3X
  68. VBA
  69. Visual Basic
  70. Visual DialogScript
  71. Yorick

Note: Some of these languages, such as PHP, Perl, Caml/OCaml, and IDL also support object oriented programming. Others on the list (C++, JavaScript, C# ) are primarily object-oriented languages which can also (though less commonly) be used to program procedurally.

Some are macro or scripting languages (Rexx, Awk, m4) which, while they do support some procedural concepts, aren't really procedural languages, but rather interpreted streams.

Also note that Assembly is NOT a high-level language, and generally is not considered a procedural language, as it doesn't have enough abstraction.

Finally, traditional COBOL is NOT a procedural language (in fact, one of the long-standing criticism of it is that it lacks any structured programming characteristics). Current-day COBOL has some ability to use procedural programming concepts, but, overall, should not be considered a real procedural language. SNOBOL is similar, in that the original version were certainly not procedural in nature, but modern versions are much more structured programming friendly (and can be considered a procedural language).

Is NET in support of object oriented language?

Yes, every language supported by Microsoft and on the .NET framework is an object oriented language. (OOP)

What are java front end tools?

Tools we used in writing codes that are not visible to the client

What is the Logic of LCM for java programs?

Factoring numbers into prime numbers, as taught in school, is much too complicated to program. To write a simple computer program, I would use the formula:

a x b = lcm(a, b) x gcd(a, d)

In other words, lcm(a, b) = a x b / gcf(a, d).

The greatest common factor can be found easily with Euclid's Formula. For example, to calculate the greatest common factor of 14 and 10:

gcf(14, 10) is the same as gcf(10, 4), where 4 is calculated as 14 % 10.

gcf(10, 4) is the same as gcf(4, 2). Again, 2 is calculated as 10 % 4.

Once you get a remainder of zero, stop. In this case, 4 % 2 = 0, so 2 is the gcf. In this case, the lcm can be calculated as 14 * 10 / 2.

How do you find all the combinations of a list?

To find the number of combinations possible for a set of objects, we need to use factorials (a shorthand way of writing n x n-1 x n-2 x ... x 1 e.g. 4! = 4 x 3 x 2 x 1). If you have a set of objects and you want to know how many different ways they can be lined up, simply find n!, the factorial of n where n is the number of objects. If there is a limit to the number of objects used, then find n!/(n-a)!, where n is the number of objects and n-a is n minus the number of objects you can use. For example, we have 10 objects but can only use 4 of them; in formula this looks like 10!/(10-4)! = 10!/6!. 10! is 10 x 9 x 8 x ... x 1 and 6! is 6 x 5 x ... x 1. This means that if we were to write out the factorials in full we would see that the 6! is cancelled out by part of the 10!, leaving just 10 x 9 x 8 x 7, which equals 5040 i.e. the number of combinations possible using only 4 objects from a set of 10.

Is a for loop a post-test loop?

Yes. The second clause (the condition) is evaluated before each iteration through a loop. It is possible that a for loop will not execute if its precondition is not met. For example, "for( int x = 5; x < 5; x++ )" will not iterate even once.

Check wheather the strings are equal?

int string_equal (char *p1,char *p2)

{

int status = 1;

while ((*p1 *p2) && status==1)

{

if (*p1++ != *p2++) status = 0;

}

return status;

}

What are the objective of restaurant billing system?

awan di alam eehh !! tanung muh sa inay , baka alam :D

Write a java program using switch case to find zodiac signs?

Let's say you want a method which will determine if the given character is a vowel, consonant, or other (non-letter).

// Will return a String representation of what the given character is:

// "vowel" "consonant" or "other"

public static final String getTypeOfChar(final char c) {

// since chars are an integer data type in Java, we can switch on them

switch(c) {

case 'a': // all of these cases "fall through" to the next non-case statement

case 'e': // if any of them matches

case 'i':

case 'o':

case 'u':

return "vowel";

case 'b': // again, all of these cases fall through

case 'c':

case 'd':

case 'f':

case 'g':

case 'h':

case 'j':

case 'k':

case 'l':

case 'm':

case 'n':

case 'p':

case 'q':

case 'r':

case 's':

case 't':

case 'v':

case 'w':

case 'x':

case 'y':

case 'z':

return "consonant";

default: // if we have no matches yet, do this

return "other";

}

}

Why might you want to define an abstract class?

You would use an abstract class when you want a number of classes to have a similar functionality/methods list. The abstract class will have only method declarations and no definitions. So any class that extends this abstract class would have to provide the method definitions. This way you can ensure that all these classes will have a similar set of methods/features. This type of usage of an abstract class is similar to interfaces.

What is the explanation for the different access modifiers in Java?

An Access Modifier is a key word in java that determines what level of access or visibility a particular java variable/method or class has. There are 4 basic access modifiers in java. They are:

  1. Public
  2. Protected
  3. Unspecified (package-private)
  4. Private

Classes can only be declared public or left unspecified (the "package-private" default level). Methods can be declared any of the above.

See the Link on the Java Tutorial for a very good explanation of the various levels of access each modifier provides.

Create an array of 10 elements in java?

to create a new Java array use

typeName[] arrayName = new typeName[10];

This gives an array with 10 elements.

To set the elements you can use

arrayName[index] = value;

Remember that the index number starts at 0, so the array will only go to index 9.

You can also declare the contents when the array is created

typeName[] arrayName = {value1, vaue2, ...}

The values used in the array must be objects. In java 5+ you can use primitive types with no concern due to auto-boxing.

Difference between include header file in C and import in java?

A) #include makes the C/C++ compiler to physically copy the entire header file code into the 'Cor C++' programs, Thus the program size will increase unnecessarily and hence it takes more memory and memory processor time.
Where as import statement makes the JVM to go to Java Library, execute the code there and substitute the result into the Java program "Here no code is copied"...................................




During compilation an .obj file will be light weight in c where as heavy during execution, which is constrant to the .class file




Sandeep Bandari (Chandurthy,9704740271)