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

Write a recursive procedure to compute the factorial of a number?

#include <iostream>

using namespace std;

int main()

{

int i, number=0, factorial=1;

// User input must be an integer number between 1 and 10

while(number<1 number>10)

{

cout << "Enter integer number (1-10) = ";

cin >> number;

}

// Calculate the factorial with a FOR loop

for(i=1; i<=number; i++)

{

factorial = factorial*i;

}

// Output result

cout << "Factorial = " << factorial << endl;

What does the byte code run on?

Bytecode runs on a virtual machine, which interprets or compiles it into machine code that can be executed by the underlying hardware. For example, Java bytecode runs on the Java Virtual Machine (JVM), while Python bytecode runs on the Python interpreter. This abstraction allows for platform independence, enabling the same bytecode to run on different systems without modification.

What is get atlcom Class?

atlcom Class is realted to programs made from Visual studio.

If you are getting pop ups run a good anti spyware program like spybot or superantispyware

What is the minimum and maximum value that a char type variable?

Character.MIN_VALUE = '\u0000' = 0

Character.MAX_VALUE = '\uFFFF' = 65535

True or false when accessing an element of an array such as numbers are the square braces called a subscript?

False. The square braces are the subscript operator. The subscript is the operand, the zero-based offset index that is passed to the operator.

Can an array contain elements of an object type?

Yes. An array of arrays is nothing more than a multi-dimensional array.

How do you write a code in java script for follow the image with cursor?

<html>

<head>

<script language="javascript">

function f_follow(event)

{

temp.style.position="absolute";//this is necessary

temp.style.left=event.clientX;

temp.style.top=event.clientY;

}

</script>

<body onmousemove="f_do(event)">

<img src="....." id="temp"/>

</body>

</html>

Given 2 int arrays a and b each length 3 return a new array length 2 containing their middle elements?

Java solution

public static final int[] getMiddle(final int[] a, final int[] b) {

return new int[] {a[1], b[1]};

}

C solution void getMiddle(const int a[], const int b[], int ret[]) {

ret[0] = a[1];

ret[1] = b[1];

}

What is the difference between the final prospectuses 424B1 424B2 etc?

All are final prospectuses, just differ in the rule they are framed.

424B1 is based on Rule 424(b)(1) on Securities Exchange Act, 1934. Similarly the others.

Why java do not support global variable declaration?

in order to acheive a inheritance and data encapsulation property global variables are not declared in java.

Who is better quick sort or merge sort?

Statistically both MergeSort and QuickSort have the same average case time: O(nlog(n)); However there are various differences.

Most implementations of Mergesort, require additional scratch space, which could bash the performance. The pros of Mergesort are: it is a stable sort, and there is no worst-case scenario.

Quicksort is often implemented inplace thus saving the performance and memory by not creating extra storage space. However the performance falls on already sorted/almost sorted lists if the pivot is not randomized.

== ==

Can you write java program in Microsoft Word?

Since the Java program is basically a text file, you can write it in any text editor (although using a Java IDE, or an IDE with support for Java, does give you certain advantages).

Thus, you can use programs such as NotePad or NotePad++ to write the Java program. Using word processors such as MS-Word is problematic, because these insert additional codes. You would have to make sure you save the resulting file in the text format - give the "Save As" command, and choose a text format from the list.

Is 'Sonic the Hedegehog' an American creation or not?

No. Sonic is a Japanese creation. He had three 'parents'... * Artist Naoto Ōshima, * Designer Hirokazu Yasuhara, * Programmer Yuji Naka,

...all from the Sega company.

What function is used to release the memory on heap?

The free() function releases memory obtained with the malloc() family of functions. The delete and delete [] operators release memory obtained with the new operator.

Note: realloc() can allocate and free memories as well as reallocate.

Is a subclass only method through a base class variable allowed?

Yes, it is allowed, but it is considered poor design to do so. The problem is not that your subclass contains a specialised, non-generic method, it is only in how you are accessing it. When you hold a variable, pointer or reference to a base class then you are expected to treat that class generically. If you cannot do this, then you should seriously rethink your design. Always ask yourself why you are attempting to extort non-generic behaviour from a generic class.

That said, it is sometimes the case that the base class design is outwith your control. It is still the result of poor design but in these cases you have little option but to make use of dynamic downcasts in order to extort specific behaviour from your subclass. The only alternative is to veto the base class completely and write your own, but if this requires a major rewrite then a dynamic downcast might be the better option in the short-term.

Another option would be to use an intermediate subclass, but this is only suitable when you have two or more subclasses that share a common interface, but where that interface is not generic enough for the base class itself. This won't resolve the problem of extorting non-generic behaviour when you hold a reference to the base class, but it can help reduce the number of dynamic downcasts to a minimum (the ideal situation is no dynamic downcasts, but the option is there if you really must use it).

Percolating the specific implementation into the base class can often be a simpler option. Although you should generally avoid this, if you are designing a closed hierarchy then the cost of the reduced encapsulation may be considered a more preferable option to the additional expense of a dynamic downcast.

What is the difference between normal variable and register variable in c?

In C/C++ when we declare a variable;

e.g

int var;

for this variable (i.e. var) memory is being reserved in RAM (i.e out side processor).

If we declare variable like that;

register int var2;

for this variable memory is being reserved in register of CPU (i.e. withing processor)

But register variables are discouraged because processor has to work with registers.....

Note: strictly speaking, storage class 'register' means: dear compiler, you might optimize this variable into register, as I won't ever request its address. But of course, it's up to you to decide.

What method returns the uppercase equivalent of a string?

The toUpperCase() method returns the uppercase equivalent of a string.

What is Design pattern in java?

The design patterns are language-independent strategies for solving common object-oriented design problems. Some common design patterns in Java are:

  • Singleton Pattern
  • Factory Pattern
  • etc

Can you declare float variable as increment operator in for loop?

I don't really understand your question, but for example the following code is perfectly legal:

float f;

for (f=0.0; f<=1.00001; f += 0.1) printf ("%g\n", f);

True or false All methods in an abstract class must be abstract?

False. In fact, it is possible to have no abstract methods in an abstract class.

What are the 5 key activities in an object-oriented design process?

1. Understand and define the context and external interactions with the system.

2. Design the system architecture.

3. Identify the principal objects in the system.

4. Develop design models.

5. Specify interfaces.

What is platform dependency?

a language is called platform dependent only if its compilation and execution depends on underlying system. the system supporting is required here