# write those 3 questions (class)

1) write a function minE which takes an array of distinct integers and returns the smallest number. (If this is too easy return the 2nd smallest element.) (If this is still too easy, also pass an int k to minE and return the k smallest element.) 2) write a function rev which takes an array of integers and reverses it. 3) write a function isDistinct which takes an array of integers and returns a boolean, indicating

October 10, 2012 at 2:55 PM

Here is an example that accepts the integers from the user and find the smallest and second smallest number from the array. It also reverses the array of numbers.

```import java.util.*;

public class Smallest {
public static void minE(int numbers[]){
int smallest = numbers[0];
int secondSmallest = numbers[1];

for (int i = 1; i < numbers.length; i++) {
if (numbers[i] < smallest) {
secondSmallest = smallest;
smallest = numbers[i];
}
}
System.out.println("Smallest value: " + smallest);
System.out.println("Second Smallest value: " + secondSmallest);
}
public static void rev(int numbers[]){
System.out.println("Numbers in reverse order: ");
for (int i = numbers.length-1; i >=0; i--) {
System.out.println(numbers[i]);
}
}
public static void main(String[] args) {
Scanner kybd = new Scanner(System.in);
int[] numbers = new int[5];

System.out.println("Enter 5 integers: ");
for (int i = 0; i < numbers.length; i++) {
numbers[i] = kybd.nextInt();
}
minE(numbers);
rev(numbers);
}
}
```

write those 3 questions (class)
write those 3 questions (class)  1) write a function minE which takes... an int k to minE and return the k smallest element.) 2) write a function rev which takes an array of integers and reverses it. 3) write a function isDistinct which
3 queries on java class
3 queries on java class  Hey. I need to do 3 queries on same class ( JAVA) One is to populate the combobox, the another one to populate tje jlist and the last one to use on button to open a file from database (BLOB) Can some
Write Full concept of abstract class
Write Full concept of abstract class  Abstract class
Write an applet program for displaying 3 different sentences with 3 different colors
Write an applet program for displaying 3 different sentences with 3 different colors  Write an applet program for displaying 3 different sentences with 3 different colors
Inner class - Java Interview Questions
Inner class  whether inner class can implement any interface(Runnable... the problem : class InnerClass1 { private int countDown = 5; private Inner inner; private class Inner extends Thread { Inner(String name
write a program to demonstrate wrapper class and its methods......
write a program to demonstrate wrapper class and its methods......  write a program to demonstrate wrapper class and its methods
questions
calculator 2. write a program to print no of days in a given month Q. 3...questions   Q. 1 programes on if....else 1. write a program... to check whether entered no. ends with 5 or not 3. write a program to find
Java Interview Questions 3
Java Interview Questions page 3   ... serialization tools that your class is serializable. Question: . How many... in order to make your class externalizable. These two methods
3
java.io package  The java.io package includes a PrintStream class that has two formatting methods that we can use to replace print () and println (). Find this two methods & Describe with your own examples
write a program to evaluate the following investment equation make use of wrapper class v=p(1+r)rest to n
write a program to evaluate the following investment equation make use of wrapper class v=p(1+r)rest to n  write a program to evaluate the following investment equation make use of wrapper class v=p(1+r)rest to n
Write a program that makes use of a class called Employee that will calculate an employee's weekly paycheque.
Write a program that makes use of a class called Employee that will calculate an employee's weekly paycheque.  Write a program that makes use of a class called Employee that will calculate an employee's weekly paycheque. Design
Given a list of methods for a stateful or stateless session bean class, define which of the following operations can be performed from each of those methods: SessionContext interface metho
Given a list of methods for a stateful or stateless session bean class... of those methods: SessionContext interface methods, UserTransaction... session bean class, define which of the following operations can
java questions
java questions  can i write an inner class in an interface
Software Questions and Answers View Software Questions and Answers online Discuss Software development questions, ask your questions and get answers online. Here you can find questions asked by developers in the past. You can
class
class  can any body give me idea how to write code for Country.java is a class to represent a country in medal tally. It has an attribute of country... medals. In this class, you should also define constructors, and assessor, mutator
Core Java Interview Questions!
Core Java Interview Questions   ... as transient in a Serializable class and the class is written... the class is retrieved from the ObjectStream the value of the variable becomes
Java write file
. In the example subclasses of  Writer abstract class are used to write... class.           Write_File... Java write file
programming questions
programming questions  this is my assignment questions please help me... Write programs with corresponding output screens to demonstrate the above concepts. Write a program in C# language to perform the following operations: a. Basic
multiple choice questions program
multiple choice questions program  how can i implement the program to store 10 multiple choice questions in one class to develop a oneline quiz with using java language
multiple choice questions program
multiple choice questions program  how can i implement the program to store 10 multiple choice questions in one class to develop a oneline quiz with using java language
Class
Area of rectangle : 6 Value of x in another class : 3 Area... Class, Object and Methods       Class : Whatever we can see in this world all the things
Spring 3
Spring 3  Hi I want to know how to write code Spring 3 for registration and login pages with help of data bse.Please help me I am new to Spring
How to write a file in Java?
How to write a file in Java? To write a file in Java use the class FileWriter and BufferedWriter. Class FileWriter: The FileWriter class is used to write... or False. BufferedWriter: The BufferWriter class is used to write data from
Java write to stream
Java write to stream       Following example demonstrates, how to write data in to the stream. In the example subclass CharArrayWriter of  abstract Writer class is used
multiple choice questions
multiple choice questions  how can i store 10 multiple choice questions in one class with using java language
multiple choice questions
multiple choice questions  how can i implement the program to store multiple questions in class with using core java concepts
servlet questions
servlet questions  pls send servlet interview questions to [email protected]
Corejava Interview,Corejava questions,Corejava Interview Questions,Corejava
;    Q 1 : How should I create an immutable class ? Ans...;     Q 3 : What is dynamic method dispatch ?  Ans... different behavior is required, you only require to write a class implementing
Java Write To InputStream
Java Write To InputStream In this tutorial you will learn how to write to InputStream in java. Write to file from InputStream in java you may use the InputStream class of java.io package. This class reads the streams of bytes
Java Questions & Java FAQ
questions about the Sun Programming Language.  Here are the list of those Java... Java Questions & Java FAQ  ... have listed the Java Questions which are commonly asked. Our collection