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

What is a large array?

one of the world’s largest radio observatories

How does a function differ from a procedure?

In closed subroutine a subroutine stored outside the main routine can be connected to it by linkages at one or more locations.

whereas in open subroutine is a set of computer instructions i.e. a subroutine that performs some particular program and insert them directly each and every time that particular function is required

Explain classes of java.lang package?

The lang package contains classes for data types like Boolean, String etc and also some other classes like Thread.

http://java.sun.com/j2se/1.4.2/docs/api/java/lang/package-summary.html

Refer this for complete details.

Difference Between interpreter and compiler in java application?

Due to platform independence, a Java compiler will interpret Java source code into Java Byte Code and pass to the JVM, which will pass machine understandable code through to cpu. (clarification needed).A conventional compiler converts source code directly to machine code.(clarification needed).

Disadvanatges of object-oriented programming languages?

  • OOP is a more complicated and structured paradigm than, say classic procedural programming.
  • More planning and design is required on the programmer's part.
  • OOP is less efficient in terms of a computer's resources than most other paradigms.
  • OOP is a complex idea - no language including Java and C++ implements it perfectly.
  • OOP may be overkill for smaller, simpler programs.

Why c is preferred over Java for embedded system?

Embedded systems typically run on extremely limited hardware. Even the smallest implementation of Java (Micro Edition) can't compete with a small C implementation both in terms of memory footprint and execution speed.

How do you write a java program to find the sum and average score of three marks scored by ten students?

import java.io.*;

class summ

{

public static void main()throws IOException

{

BufferedReader in=new BufferedReader(new InputStreamReader(System.in));

int a[]=new int[10];

int sum=0;

float avg=0;

for(int i=0;i<10;i++)

{

System.out.println("Enter marks of student "+(i+1)+" : ");

a[i]=Integer.parseInt(in.readLine());

sum+=a[i];

avg=sum;

}

avg/=10;

System.out.print("Sum= "+sum+"\nAverage= "+avg);

}

}

Is 'k equals k plus 1' same as 'k plus equals 1' in Java?

Yes, they are exactly the same, both of them increment k in 1.

Write a program take three strings from the command line and display the number of characters in each string in java?

class BackString

{

public static void main(String[] args)

{

//work out the length of args[]

int len=args.length;

//cycle forwards through the array string

for (int i=0; i<len; i++)

{

//how long is the word in characters?

int wordLen = args[i].length();

//cycle backwards through the word a char at a time

for (int j=wordLen-1; j>=0; j--)

{

System.out.print(args[i].charAt(j));

}

System.out.print(" ");

}

}

}

What is the major difference in class and interface in c?

The implementation detail. Classes may provide a default implementation, interfaces provide only the method signatures

What do you compile?

Compiling is the act of translating human-readable source code to machine-readable byte code.

In Java, the compiler program is javac

Program for doing upercase of 1st letter of string?

#include<stdio.h>

#include<conio.h>

#include<ctype.h>

main()

{

char string[80];

int n,k=0;

clrscr();

while((string[k]=getche())!='\r')

k++;

string[k]='\0';

n=k;

k=0;

while(k<n)

{

putchar(toupper(string[k]));

k++;

}

}

Algorithm for infix to prefix conversion?

Algorithm to Convert Infix to Prefix Form

Suppose A is an arithmetic expression written in infix form. The algorithm finds equivalent prefix expression B.

Step 1. Push ")" onto STACK, and add "(" to end of the A

Step 2. Scan A from right to left and repeat step 3 to 6 for each element of A until the STACK is empty

Step 3. If an operand is encountered add it to B

Step 4. If a right parenthesis is encountered push it onto STACK

Step 5. If an operator is encountered then:

a. Repeatedly pop from STACK and add to B each operator (on the top of STACK) which has same or higher precedence than the operator.

b. Add operator to STACK

Step 6. If left parenthesis is encontered then

a. Repeatedly pop from the STACK and add to B (each operator on top of stack until a left parenthesis is encounterd)

b. Remove the left parenthesis

Step 7. Exit

How do you get a default constructor?

The default constructor is an empty (only call the super constructor) with no parameters constructor inserted by the java compiler when you don't define a constructor in your class. If you write something like this:

public class NoConstructorClass{

//no constructor goes here

}

Then you get something like this:

public class NoConstructorClass{

public NoConstructorClass(){ // Default constructor that you didn't write

super();

}

}

What is a default package in Java?

A default package is a package with no name. You can create a Java class without putting package name on top of the code. This class is included in the "default package".

Be careful not to be confused with java.lang, which is a package that contains Java's fundamental classes and get's imported by default.

Download JRE 1.5.0 09 for Vista?

You can download the Sun Java JRE Version 1.5.0_09 Here: http://java.sun.com/products/archive/j2se/5.0_09/index.html

What are arrays?

  • Array data structure, an arrangement of items at equally spaced addresses in computer memory
  • Array data type, used in a programming language to specify a variable that can be indexed
  • Associative array, an abstract data structure model that generalizes arrays to arbitrary indices

or various kinds of the above, such as

  • Bit array or bit vector
  • Dynamic array, allocated at run time
  • Parallel array of records, with each field stored as a separate array
  • Sparse array, with most elements omitted, to store a sparse matrix
  • Variable-length array
  • Ragged (jagged) array, where the rows have different lengths individually

or various related concepts:

  • Array processor, a computer to process arrays of data (not to be confused with a processor array)
  • Array programming, using matrix algebra notation in programs (not the same as array processing)
  • Array slicing, the extraction of sub-arrays of an array
  • APL (programming language)

or also:

  • Video Graphics Array (VGA), a display adapter and video format, and many variants thereof (EVGA, FWVGA, QVGA, QXGA, SVGA, SXGA, SXGA+, TXGA, UVGA, XGA, XGA+, ...)

What is it called when java allows you to declare methods with the same name in a class?

Yes perfectly Legal

Reason:

The scope of a variable declared inside a method is only till the method's end. So by defining another variable of the same name inside a different method does not create any issues.

Why do you need runnable interface?

A Runnable Interface is one that is used to create a Java Thread...

A Thread can be created in two ways and using the Runnable Interface is one of them.

Example:

public class Test implements Runnable {

public void run(){

....

}

}

The Runnable interface would have an abstract instance of the method run() which needs to be implemented in the class which wants to create a Thread.

What is the difference between a constant and a variable in java programming language?

A constant in Java is defined using the "final" modifier. For instance:

final double Density_Of_Water = 1.000;

would set Density_Of_Water to 1.000. This value can not be modified throughout the program because "final" told the compiler that this value would not change. A variable however, can be changed by the user throughout the program.

How do you find the greatest of two numbers without using the if-else comparison operators?

By subtracting any two of the numbers A-B , if the output number is negative , B IS GREAT and if its positive A is great

Why you use API rather than System Calls?

System calls are much slower than APIs (library calls) since for each system call, a context switch has to occur to load the OS (which then serves the system call).

How develop java calculator using awt?

import java.io.*;

import java.util.*;

public class Calculator

{

public static void main(String args[])

{

System.out.println("Make your arithmetic selection from the choices below:\n");

System.out.println(" 1. Addition");

System.out.println(" 2. Subtraction");

System.out.println(" 3. Multiplication");

System.out.println(" 4. Division\n");

System.out.print(" Your choice? ");

Scanner kbReader = new Scanner(System.in);

int choice = kbReader.nextInt();

if((choice<=4) && (choice>0))

{

System.out.print("\nEnter first operand. ");

double op1 = kbReader.nextDouble();

System.out.print("\nEnter second operand.");

double op2 = kbReader.nextDouble();

System.out.println("");

switch (choice)

{

case 1: //addition

System.out.println(op1 + " plus " + op2 + " = " + (op1 + op2) );

break;

case 2: //subtraction

System.out.println(op1 + " minus " + op2 + " = " + (op1 - op2) );

break;

case 3: //multiplication

System.out.println(op1 + " times " + op2 + " = " + (op1 * op2) );

break;

case 4: //division

System.out.println(op1 + " divided by " + op2 + " = " + (op1 / op2) );

}

}

else

{

System.out.println("Please enter a 1, 2, 3, or 4.");

}

}

}

Define java virtual machine in java?

A Java Virtual Machine (JVM) is a set of computer software programs that use a virtual machine model for the execution of Java computer programs and scripts.

The JVM accepts data in a form commonly referred to as Java bytecode. This language conceptually represents the instruction set of a stack-oriented, capability architecture.