Meena

Greenhorn
+ Follow
since Sep 29, 1999
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Meena

Q2>
public class lost {
public static void main (String [] args){
int [] array = new int[10];
int i=5;
array[i++]=i+++i++;
System.out.println(array[5]+" "+array[6]+" "+i);
}
}
When i tried to execute this code,i got output as 13 0 8.
Can anybody try to explain this.
Q1>
public class lost {
public static void main (String [] args){
int [] array = new int[10];
int i=5;
array[i++]=++i+i++;
System.out.println(array[5]+" "+array[6]+" "+i);
}
}
When i tried to execute this code,i got answers to be as 14 0 8.
Could anybody answer how it could be 14 0 8.
because i think that array[i++]=++i+i++;for
int i = 5 is
array[5]=6+5=11.
array[6]=?
i=?
I have a variety of different Java materials and books in which variables are described with completely different adjectives. I just wish there was a concensus.
Which of these words mean the same exact thing, and what specifically do they mean?
"automatic" variable
"local" variable
"member" variable
"method" variable
"method level" variable
"instance" variable
"class" variable
Question 1: If I wanted words to describe variables that are in a class body but outside of methods or constructors, wich of the above adjectives would I use?
Question 2: If I wanted words to describe variables that are in a method body within a class, which of the above adjectives would I use?
Question 3: If I wanted words to describe variables that are in a class within another class, which of the above adjectives would I use?
Question 4: Is there another category that I didn't mention in Question 1 - Question 3 above?

Thanks!
Here is the definition for "encapsulation" in the book The Java Tutorial 2nd ed -"Hiding information within an object's nucleus and then providing a public interface for interacting with it is called encapsulation". The definition in Marcus Green's Tutorial is the same.
However, what specifically does this mean? Which of the following would be true statements to describe the concept of encapsulation?
Variables must be private?
Variables must be public?
Methods must be private?
Methods must be public?
Classes must be private?
Classes must be public?
Constructors must be private?
Constructors must be public?
Something else - like maybe - objects can only be modified via instanciating a method? Or objects can only be modified via instanciating a class?
Thanks!
class Question {
static int i=1,j=2;
static {
display(i);
}
public static void main(String[] args) {
display(j);
}
static void display(int n) {
System.out.print(n);
}
}
A)1
B)2
C)12
D)4
The answer for this is C)12 in Mock exam.
But as for as i know,The static initializer is executed follwed by main.
so i guess the answer should be 1.
What do you think.
I could no get your output.
How does the boolean get byte 1,
Int gets byte 2 - 5, Int gets 6 - 9
Will you try to explain it.

1Q)What output is displayed by the following program?
import java.io.*;
public class TestIOApp {
public static void main(Strin args[]) throws IOException {
RandomAccessFile file = new RandomAccessFile("test.txt", "rw");
file.writeBoolean(true);
file.writeInt(123456);
file.writeInt(7890);
file.writeLong(1000000);
file.writeInt(777);
file.writeFloat(.0001f);
file.seek(5);
System.out.println(file.readInt());
file.close();
}
}
A)123456
B)7890
C)1000000
D)777
E).0001
The answer is B)How? Please anybody explain it.

2Q)What is the value displayed by the following program?
class Question {
static boolean sideEffect(boolean b) {
System.out.print("side effect");
return b;
}
public static void main(String[] args) {
boolean b1 = true;
boolean b2 = false;
if(b2 & sideEffect(b1)) System.out.println(1);
else if(b1 | sideEffect(b2)) System.out.println(2);
}
}
A)1
B)2
C)side effect 1
D)side effect 2
E)side effect side effect 1
F)side effect side effect 2
The answer is F). How? Please anybody explain it.
Iam getting this stuff from different mock exams posted on the web.
Thank you.
1) How are thread priorities and thread scheduling related?
a. they aren't
b. it depends on the thread-scheduling algorithm used to implement the JVM
c. thread priority is specified when a thread is to be excuted next.
d. thread priority is used to determing the next thread to execute from the waiting thread pool.

2) java_g is used for which of the following?
a. executing a class with optimization turned off.
b. using the jdb tool.
c. compiling the specified source without optimization.
d. a and b.
3) the JVM specification defines the process by which unused memory resources are collected and put onto the heap of resues
a. true
b. false

4) which is not the method of java.lang.Object
a. wait()
b. equals(object)
c. getHashcode()
d. notify()
5) java.lang.Thread utilizes which of the following methods to relinquish the thread instance's processing slot to another thread?
a. sleep()
b. wait()
c. notify()

6) java_w performs which of the following?
a. executes a specified class
b. executes a specified class without window optimization
c. executes a specified class in its own separate window
d. execites a specified class without an associated console window.
Thanks simon.I have clearly understood your
explanation.
1)Given this code snippet:
: double a = 90.7;
: double b = method(a);
: System.out.println(b);
: If this snippet displays 90 in the standard output, what Math method did method() invoke?
:
: Select all valid answers.
: a)abs()
: b)min()
: c)floor()
: d)round()
: e)ceil()
:
: 2)Given this code snippet:
: double a = 14.9;
: double b = method(a);
: System.out.println(b);
: If this snippet displays 15.0 in the standard output, what Math method(s) could method() have invoke?
: Select the one right answer.
: a)ceil() and round()
: b)floor() and round()
: c)ceil() only
: d)floor() only
: e)round() only
: What could be the answers for this?will you please explain it.