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 are the main ways of exiting a program?

Other than throwing an exception or a run-time library error, or forcibly terminating the process, there is only one way of exiting a program; you return from the entry point function, usually main(), provided by the library, or from winmain(), if you are using Windows.

Describe the difference between Interface-oriented Object-oriented and Aspect-oriented programming?

In object oriented programming cross cutting concerns cannot be implemented while in aspect-oriented these can be implemented easily, but if there is a logic mistake in implementing these cross-cutting concerns then the whole system will fail. In case of object-oriented whole system will not fail.(Excerpt from FrazzledDad blog @ http://frazzleddad.blogspot.com)Aspect-OrientedAspect-oriented programming looks at how many components or pieces of a system might need to interact. The intersections of these pieces are what are important in AOP. "Crosscutting" is a slice across several units, all of which interact during some operation. The article Discussing aspects of AOP in Communications of the ACM, Volume 44, Number 10 (2001) shows an example of a drawing editor with point and line elements. If the drawing is moved, both point and line elements need to update. A crosscut hits these elements for this event. Other examples might include logging or exception handling which hit several different layers in a system. (Viji Sarathy, Aspect Orienting .NET Components )Interface-OrientedInterface-oriented programming is a contract-based approach. Nether side of the interface cares how the other does its work, only that the two sides can communicate via an agreed-upon contract. WSDL-based web services are the prime example of this.Object-OrientedObject-Oriented programming is based on abstraction, encapsulation (data hiding), polymorphism and inheritance. Classes implement these concepts to build objects controlling or implementing a system.Abstraction allows loose coupling between components by providing a layer between objects so that one object isn't concerned with how the other implements its business rules. (Interfaces, layers) Great stuff when you want to isolate parts of the system so they can be swapped out without killing the rest of the sytsem.Encapsulation allows abstraction to work by hiding details of a class's implementation from calling classes. (Public vs. private fields)Inheritance enables base (parent) classes to have common functionality defined in it and passed down to child classes. A Shape class might have a field for color which is inherited by child classes of Square or Circle type.Polymorphism enables implementation of same-named public fields, allowing different classes to perform different actions on the same call - rendering a Square or Circle object differently in a graphic program, even though they might both be subclassed from a base Shape class. (Overriding)

Sort the following numbers 19 5 28 2 7 using bubble sort?

Passes:

bold are "sunk" into place

1: 5 19 2 7 28

2: 5 2 7 19 28

3: 2 5 7 19 28

4*: 2 5 7 19 28

*The last pass had no swaps, thus it breaks out of the sort

Efficiency: O(n^2) in random order O(n) when already sorted

Which program translates an assembly language program into a high-level language?

A High level language is a language like C, Pascal, Fortran. To convert, the easiest way is to use a compiler.

A compiler will take the instructions written in a high level language and convert them into machine code which is the specific instruction set for that type of computer. Assembly language is just a human readable form of a machine code which is how the designers of the computer instruction set made it work.

A disassembler will show the assembly language from machine code. But the compiler usually includes a lot of optimisations from a the high level language and will not often generate very simple assembly.

Memorymically and and not reclaming it when it is no longer it is needed in java there is no such problem as there is as garbage collector what is it?

I guess you want to talk about the garbage collector feature that Java has.

The garbage collector is an automated program that the Java virtual machine would run once in a while. This program would clean up unused memory to ensure that there is enough memory available for the programs.

you can invoke the garbage collector by calling the system.gc() method but this does not guarantee an invocation of the garbage collector. the JVM may or may not call the GC when we invoke it...

Write a program to transpose of a matrix?

Program to find the Transpose of a Matrix

#include

#include

void main()

{

int i,j,n,t;

int m[5][5];

clrscr();

printf("Enter Order of Matrix : ");

scanf("%d",&n);

printf("Enter Elements of Matrix :\n\n");

for(i=0;i

{

for(j=0;j

{

scanf("%d",&m[i][j]);

}

}

printf("Transpose of the Matrix :\n\n");

for(i=0;i

{

for(j=i+1;j

{

t=m[i][j];

m[i][j]=m[j][i];

m[j][i]=t;

}

}

for(i=0;i

{

for(j=0;j

{

printf("\t%d",m[i][j]);

}

printf("\n");

}

getch();

}

Output:

Enter Order of Matrix : 3

Enter Elements of Matrix :

45 56 96

75 36 15

29 64 81

Transpose of the Matrix :

45 75 29

56 36 64

96 15 81

with out using temp variable:

#include

#include

void main()

{

int i,j,n,t;

int m[5][5];

clrscr();

printf("Enter Order of Matrix : ");

scanf("%d",&n);

printf("Enter Elements of Matrix :\n\n");

for(i=0;i

{

for(j=0;j

{

scanf("%d",&m[i][j]);

}

}

printf("Transpose of the Matrix :\n\n");

for(i=0;i

{

for(j=i+1;j

{

m[j][i]=(m[i][j]+m[j][i]-(m[i][j]=m[j][i]));

}

}

for(i=0;i

{

for(j=0;j

{

printf("\t%d",m[i][j]);

}

printf("\n");

}

getch();

}

What is whitespace in java program?

Any spaces, tabs, or blank lines, that don't contain actual commands. Whitespace is used to separate keywords, variables, etc. Whether you put a single space, several spaces, an ENTER, or some other combination is irrelevant for the compiler, but it is still extremely important to use proper indentation, because otherwise, the program will be very confusing for a human to read.

Write 8085 program on bubble sort algorithm?

The basic algorithm for a bubble sort requires a boolean indicator. As the program cycles through the array to be sorted, it steps by one and compares n and n+1. If n+1 is greater than n, then they are swapped, the boolean indicator is set to false and the comparator increments by one. Once the comparator makes a complete cycle through without the indicator flagging to false, the array is sorted.

What did you learn anything useful from high school computer class about java programming?

Java programming is very important because it can help you make web applications. Thanks for one reason but I need more reasons for my opinion piece!

When was Conversations with Inanimate Objects created?

Conversations with Inanimate Objects was created in 2005.

Which os is build in Java compiler?

Java compiler available on multiple platforms, the class files it generates are platform-independent.

Is it safe to download Java software?

Anytime you download software the will be executed on your computer, you face risks. Make sure you know the source of the software. Then you can judge whether or not the level of risk is acceptable vs. the potential benefits of the software.

What is low-level symbolic programming language?

In contrast to a high-level language, which formats itself more to allow the programmer to understand his/her work and program flow, a low-level language formats itself in terms of a computer's or circuit's own internal structure. Rather than you saying what you want to do and letting the compiler figure out how to tell the machine what to do, you're basically telling the machine directly what to do: in its own "words," so to speak.

Assembler languages are perhaps the best-known low-level languages.

What is Function oriented design?

Function oriented design breaks a system down into one or more named functions which transform their inputs to produce an output, such that the output of one function may be used as input to another function. In addition, the system also typically provides a global state which any function may operate upon.

In order for the "system of functions" to operate there has to be single point of entry which is typically provided by the system's global main function. The inputs for this particular function are derived from the command line used to invoke the system while the output is an integer typically used to indicate a system-defined error (with the value 0 usually indicating no error). Typically, the global main function decodes the command line parameters to determine what work is to be performed (if any) and to delegate that work to an appropriate function.

Although a single function can perform a significant amount of work, complex systems are much easier to understand when the work is divided amongst many smaller, simpler functions. When the functions are appropriately named, code becomes largely self-documenting, with the low-level implementation details largely hidden from the user.

What is JDBC package in java?

JDBC stands for Java Data Base Connectivity. As the name suggests the package is reposnisble for database connectivity. It is a standard API defined for database access.

Is interface class a valid term?

Yes. An interface in essence is a java class and so you can use the term interface class. But, using the term class along with the term interface can cause ambiguity or misunderstandings among novice java developers. So, using the term "Interface" along would suffice to refer to a type of class which is the "Interface"

How do you choose the version of Java to use with your browser when you have more than one version of Java installed?

Its good practice to always use the most recent version of the respective software system you are trying to run. In the case of Java that means you want to run Java JRE 1.6 for pretty much everything. You also may want to consider removing the older versions of Java as they may conflict with the newer version.

How do you code a program to find kaprekar number?

import java.io.*;

class kaprekar

{

public static void main(String args[])throws IOException

{

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

System.out.println("Enter any number");

int n=Integer.parseInt(br.readLine());

int t=n,count=0;

while(n!=0)

{

n=n/10;

count++;

}

int s=t*t;

int p=(int)Math.pow(10,count);

int ld=s%p;

int minus=s-ld;

int fd=minus/p;

int sum=fd+ld;

if(sum==t)

{

System.out.println("Kaprekar Number");

}

else

{

System.out.println("Not a Kaprekar number");

}

}

}

Which awt component can hold a menu in advanced java?

There are classes in java.awt Menu and MenuItem which are used for the creation of menus and they can be put inside Frame.

Fetching data from excel sheet from Java?

The Apache POI project is a Java API to read and write Microsoft Documents.


The API allows you can read and write MS Excel files using Java.