viva questions - any ideas?

M

Madhur Ahuja

Hello

My instructor gave me some sample viva questions.
Some of the questions, were quite odd.

I have searched the net for their answers, I just decided
to post them here, to get ideas of your people.

Q. What is the data structure used in the garbage collection
scheme of java[ or perhaps sun's jvm].
A. I have found that, implementation of garbage collection is
implementation dependent. java specification only specifies
what is garbage collection and not what algorithm to apply.

As regard of sun's jvm, i have found that it uses
*reference counting collectors* algorithm to find out unused
objects.

Q. How is the memory map of a static variable, different from that
of non static variable.
A. This one is quite odd. I think it depends on the OS,platform
etc. In short one can say that only one copy of static variable is
maintained for a class having multiple instances.

Q. Can you override public static void main method?
A. No. Since it is a static method. Although no error will be
generated.

Q. What is the latest version of J2EE
A. Same as JDK I think? 1.5 or JSDK 5.0

Q. What is the meaning of 2 in J2SDK and 1,4 in Java 1.4
A. This confuses me lot. Perhaps anyone can help in this case. Also
the latest 1.5 has been termed as 5.0.

Q. What do u know about drafts,specifications of J2SE?
A. Drafts? no idea about this. Perhaps these are same as versions.

Q. What are the components of JFC?
A. Swing, AWT.

Q. What are the disadvantages of Swing over AWT?
A. Might be little slow.

Q. What are the major changes in java from versions 1.1,1.2,1.3,1.4
A. Although the answer of this question is best found on the Sun's site.
My instructor told that he was interested in the version groups of java.
For ex, 1.1-1.2 is regarded as similar java version while 1.3-1.4 is
regarded as another equal java version. Has anyone ideas on this?

Q. There is a famous trick in java programming to prevent the
decompilation of your .class files(may be not successful).
what is that trick?
A. I have found about "encrypting the class files and decrypting them
while loading through a custom classloader inside the JVM". This
fails due to a API, which directly takes the unencrypted class files
as an argument.(taken from the www.javaworld.com)
 
O

Oscar kind

Madhur Ahuja said:
My instructor gave me some sample viva questions.
Some of the questions, were quite odd.

And you provided your own answers. Good work!
My notes are below.

Q. What is the data structure used in the garbage collection
scheme of java[ or perhaps sun's jvm].

The structure is irrelevant to programming. What is relevant, is that you
don't know when an object is collected (and in general you cannot force
garbage collection).

Q. How is the memory map of a static variable, different from that
of non static variable.
A. This one is quite odd. I think it depends on the OS,platform
etc. In short one can say that only one copy of static variable is
maintained for a class having multiple instances.

IMNSHO, the question is poorly worded. Your answer is correct though.

Q. Can you override public static void main method?
A. No. Since it is a static method. Although no error will be
generated.

Correct. Note that the compiled class actually calls the method on the
class. The compiler silently translated a call to staticMethod() into
TheClass.staticMethod(), thus creating the illusion of inheritance. But
static methods are not included in the inheritance hierarchy, and thus
cannot be overridden.

Q. What is the latest version of J2EE
A. Same as JDK I think? 1.5 or JSDK 5.0

J2EE is different from the JDK. The latest version is 1.4. See:
http://java.sun.com/j2ee/

Q. What is the meaning of 2 in J2SDK and 1,4 in Java 1.4
A. This confuses me lot. Perhaps anyone can help in this case. Also
the latest 1.5 has been termed as 5.0.

After Java 1.0 and 1.1, the API received a major overhaul. Subsequent
versions were called Java2, but the numbering of the individual versions
did not change (thus 1.2.x, 1.3.x and 1.4.x).

With the arrival of generics, enumerations, autoboxing and the other
janguage changes in Java, the "family version" (for lack of a better term)
was increased again. This time to 5. I don't know why.

Q. What do u know about drafts,specifications of J2SE?
A. Drafts? no idea about this. Perhaps these are same as versions.

No. For each of the new features of 1.5, there was a draft specification.
These have been incorporated in the general Java specification, which all
JVM's must adhere to be allowed to call themselves a Java Virtual Machine.

Q. What are the disadvantages of Swing over AWT?
A. Might be little slow.

Also, AWT depends more on the underlying platform, and thus has subtle
incompatibilities across platforms. These cannot be solved by programmers
that just use the Java API.

Other than by using Swingg that is.

Q. What are the major changes in java from versions 1.1,1.2,1.3,1.4
A. Although the answer of this question is best found on the Sun's site.
My instructor told that he was interested in the version groups of java.
For ex, 1.1-1.2 is regarded as similar java version while 1.3-1.4 is
regarded as another equal java version. Has anyone ideas on this?

Java 1: 1.0-1.1 (initial version)
Java 2: 1.2-1.4 (major overhaul of the API)
Java 5: 1.5 (introduction of new language features)

Q. There is a famous trick in java programming to prevent the
decompilation of your .class files(may be not successful).
what is that trick?
A. I have found about "encrypting the class files and decrypting them
while loading through a custom classloader inside the JVM". This
fails due to a API, which directly takes the unencrypted class files
as an argument.(taken from the www.javaworld.com)

The "trick" is obfuscation. It uses the fact than Java bytecode is more
similar to machine code than to Java.

Obfuscation cannot be perfect because the functionality is preserved. And
with a special JVM reverse engeneering is always possible. However, some
obfuscators can mangle the bytecode such that the original code structure
is destroyed beyond automated decompilation.

In most cases however, reverse engeneering a key component (for example a
licence key checker) is still too easy for comfort. Determining a way for
the customers to want to connect to one of your servers over the internet
is a much better way to guarantee sales (the server denies access to
illegal/duplicate licence keys).
 
M

Michael Borgwardt

Madhur said:
As regard of sun's jvm, i have found that it uses
*reference counting collectors* algorithm to find out unused
objects.

No. This is wrong.
Q. What are the disadvantages of Swing over AWT?
A. Might be little slow.

Not necessarily. The main disadvantage (as people seem to see it)
is that it's not available until Java 1.2 and thus cannot be used
in applets that are supposed to run in the outdated Microsoft JVM.
Q. What are the major changes in java from versions 1.1,1.2,1.3,1.4
A. Although the answer of this question is best found on the Sun's site.
My instructor told that he was interested in the version groups of java.
For ex, 1.1-1.2 is regarded as similar java version while 1.3-1.4 is
regarded as another equal java version. Has anyone ideas on this?

That doesn't make sense. The difference between 1.1 and 1.2 is much,
MUCH bigger than between 1.2 and 1.3.
Q. There is a famous trick in java programming to prevent the
decompilation of your .class files(may be not successful).
what is that trick?

Not giving the .class files away.
 
C

Chris Smith

Michael said:
That doesn't make sense. The difference between 1.1 and 1.2 is much,
MUCH bigger than between 1.2 and 1.3.

This depends on where you're looking, too. The Java standard API
underwent a huge expansion between 1.1 and 1.2, but if I were only
considering the language and truly core API, I wouldn't say Java changed
at all! On the other hand, the language changed a lot in the 1.0 to 1.1
transition. Both language and API underwent moderate changes from 1.3
to 1.4, and they both changed to a greater extent again from 1.4 to 1.5.

The only really "minor" version change from BOTH a language and API
standpoint appears to be from 1.2 to 1.3.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
A

Andrew Thompson

The only really "minor" version change from BOTH a language and API
standpoint appears to be from 1.2 to 1.3.

I regard the introduction of the JNLP API in 1.3 to have been
significant, but that is because deployment is such a quirky
(and often overlooked) matter.
 
T

Thomas Weidenfeller

Madhur said:
My instructor gave me some sample viva questions.
Some of the questions, were quite odd.

They are indeed. However, some of your answers are also odd :)
I will add a "disagree" to the answers where I think that you should put
some more work in, and do some more research.
Q. What is the data structure used in the garbage collection
scheme of java[ or perhaps sun's jvm].
A. I have found that, implementation of garbage collection is
implementation dependent. java specification only specifies
what is garbage collection and not what algorithm to apply.
As regard of sun's jvm, i have found that it uses
*reference counting collectors* algorithm to find out unused
objects.
disagree

Q. How is the memory map of a static variable, different from that
of non static variable.
A. This one is quite odd. I think it depends on the OS,platform
etc. In short one can say that only one copy of static variable is
maintained for a class having multiple instances.

The question can indeed be interpreted in different ways, and the term
"memory map" is odd. I would have constructed my answere around what is
supported in the java "assembler language".
Q. What is the meaning of 2 in J2SDK and 1,4 in Java 1.4
A. This confuses me lot. Perhaps anyone can help in this case. Also
the latest 1.5 has been termed as 5.0.

This question is indeed odd. Many will answer that it is just a
marketing stunt from Sun, but your instructor might be after something
completely different (maybe Sun's marketing blurb about the '2'?).

BTW: Do you pay much for this course? Can you change to a better
instructor? I mean, even many of the non-odd questions are IMHO not to
significant. There are much more important things to know about Java
than that stuff.
Q. What do u know about drafts,specifications of J2SE?
A. Drafts? no idea about this. Perhaps these are same as versions.

Also odd. Maybe he is after JLS and JSP stuff?
Q. What are the components of JFC?
A. Swing, AWT.

Disagree. The definition of JFC was never to precise, but you IMHO
missed one important part.
Q. What are the disadvantages of Swing over AWT?
A. Might be little slow.

Oh well ... A lot of this is just opinions, and the actual advantages
and disadvantages depend much on the context in which you use it. Indeed
an odd question. Your instructor has most likely a particular opinion -
maybe you find it in your course notes. But if this is what they teach
you, then the course is not of the best quality.
Q. What are the major changes in java from versions 1.1,1.2,1.3,1.4
A. Although the answer of this question is best found on the Sun's site.
My instructor told that he was interested in the version groups of java.
For ex, 1.1-1.2 is regarded as similar java version while 1.3-1.4 is
regarded as another equal java version. Has anyone ideas on this?

Also an odd question, because the answer depends much on how one defines
"similar", and if this is only about the Java the language, or the
APIs, the class file format, the VM or whatever.
Q. There is a famous trick in java programming to prevent the
decompilation of your .class files(may be not successful).
what is that trick?
A. I have found about "encrypting the class files and decrypting them
while loading through a custom classloader inside the JVM". This
fails due to a API, which directly takes the unencrypted class files
as an argument.(taken from the www.javaworld.com)

Disagree. This is definitely not what your instructor is after. But the
question is also strange. The "trick" is not "famous", but just common.

/Thomas
 
V

VisionSet

Michael Borgwardt said:
No. This is wrong.


Not necessarily. The main disadvantage (as people seem to see it)
is that it's not available until Java 1.2 and thus cannot be used
in applets that are supposed to run in the outdated Microsoft JVM.

And that Swing *can* provide a more cross platform look to an application
where as awt uses the native toolkit.
 
M

Madhur Ahuja

Thomas Weidenfeller said:
Madhur said:
My instructor gave me some sample viva questions.
Some of the questions, were quite odd.

They are indeed. However, some of your answers are also odd :)
I will add a "disagree" to the answers where I think that you should
put some more work in, and do some more research.
Q. What is the data structure used in the garbage collection
scheme of java[ or perhaps sun's jvm].
A. I have found that, implementation of garbage collection is
implementation dependent. java specification only specifies
what is garbage collection and not what algorithm to apply.
As regard of sun's jvm, i have found that it uses
*reference counting collectors* algorithm to find out unused
objects.

disagree

I have searched a lot but not found exactly which *algorithm*.

[...]
Oh well ... A lot of this is just opinions, and the actual advantages
and disadvantages depend much on the context in which you use it.
Indeed an odd question. Your instructor has most likely a particular
opinion - maybe you find it in your course notes. But if this is what
they teach you, then the course is not of the best quality.

Actually this is not what they teach, but these are viva questions.
viva questions here are generally more of a *research type* questions
rather than straight simple java concepts. Sometimes they even do not
have answers, they just exist to check the confidence of level and
understanding of student.
 
C

Carl Howells

Madhur said:
Thomas Weidenfeller said:
Madhur said:
My instructor gave me some sample viva questions.
Some of the questions, were quite odd.

They are indeed. However, some of your answers are also odd :)
I will add a "disagree" to the answers where I think that you should
put some more work in, and do some more research.

Q. What is the data structure used in the garbage collection
scheme of java[ or perhaps sun's jvm].
A. I have found that, implementation of garbage collection is
implementation dependent. java specification only specifies
what is garbage collection and not what algorithm to apply.
As regard of sun's jvm, i have found that it uses
*reference counting collectors* algorithm to find out unused
objects.

disagree


I have searched a lot but not found exactly which *algorithm*.

Sun's recent JVM's have used several different strategies. The basic
approaches are typically a generational copying collector for new
objects, and mark-and-sweep for objects which survive the first couple
generations of the copying collector.

Those are only general strategies, though. The exact algorithms used
depend on the JVM options set, with different variations available for
optimizing for different memory-use and latency vs. throughput
considerations.

In other words, there isn't one answer to the question "What algorithm
does it use?".
 
N

Nigel Wade

Madhur said:
Thomas Weidenfeller said:
Madhur said:
My instructor gave me some sample viva questions.
Some of the questions, were quite odd.

They are indeed. However, some of your answers are also odd :)
I will add a "disagree" to the answers where I think that you should
put some more work in, and do some more research.
Q. What is the data structure used in the garbage collection
scheme of java[ or perhaps sun's jvm].
A. I have found that, implementation of garbage collection is
implementation dependent. java specification only specifies
what is garbage collection and not what algorithm to apply.
As regard of sun's jvm, i have found that it uses
*reference counting collectors* algorithm to find out unused
objects.

disagree

I have searched a lot but not found exactly which *algorithm*.

Have a look at:

http://java.sun.com/docs/hotspot/gc1.4.2/
 
T

Thomas Weidenfeller

Madhur said:
I have searched a lot but not found exactly which *algorithm*.

Several :) Sun has published several papers about the GC algorithms
they use. It should all be on java.sun.com somewhere. You can also
configure the algorithm on the command line of Sun's VM. That should be
described in the tool documentation of the JRE - which is also at the
above mentioned web site.
Actually this is not what they teach, but these are viva questions.
viva questions here are generally more of a *research type* questions
rather than straight simple java concepts. Sometimes they even do not
have answers, they just exist to check the confidence of level and
understanding of student.

Well, I think some of them are not even worth researching ...

/Thomas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top