• Post Reply Bookmark Topic Watch Topic
  • New Topic

Revision  RSS feed

 
Stephen Foy
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just revising for my exams, and ive made some questions for myself to answer, ive answered most of them in my words, if anyone could answer some in there terms so i can compare them to my answers it would help greatly in my revision.

�Explain the difference between a syntax error and a Java Exception.
�What is the difference between checked and unchecked exceptions in java?
�Describe static data and dynamic data. Which is more useful, and why?
�Why do some methods use �void�in their header while others use a type e.g. String or int?
�Why do some methods use �static�in their header while others do not?
�What are formal parameters, and how are they different from actual parameters?
�Describe the parameter-passing mechanism of a value parameter and a reference parameter.
�Explain the difference between an instance variable and a class variable.
�What are syntax errors & how are they detected?
�What are logic errors & how are they detected?
�Explain the difference between dynamic arrays and static arrays.
�How is a dynamic array declared, initialised and processed? How does that different from the handling of a static array?
�What is a primitive data type in Java, and what happens in memory when it is declared & initialised?.


questions on OOP concepts

�What is the difference between the declaration of an object and the instantiation of an object?
�Explain why Java objects occupy unpredictable amounts of memory, and explain what happens in memory at the declaration of an object.
�Explain the three categories of method in java: constructor methods, instance methods and class methods.
�What effect does it have to use each of the following access modifiers: private, public, protected ?
�What is meant by encapsulation in OOP and how does it lead to an abstract data type?
�What is meant by polymorphism in OOP?
�What are primitive data types in Java, and how do they differ from Java objects?
�When a Java object is declared & instantiated, what happens in memory?




questions on superclasses & subclasses


�draw a diagram representing the data inheritance relationship between the two classes
�what effect does super have when used in the given subclass?
�what effect does this have when used in the given subclass?
�what effect does this have when used in the given superclass?
�which methods are available to objects from the superclass?
�which methods are available to objects from the subclass?
�why are some methods �static� but others are not?
�why are some methods �public� and others �private�/�protected�?
�why are some variables/methods �protected� and others �private�?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not provide your answers, and we'll critique them. Give a little, get a little, right?
 
Stephen Foy
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Np, ill type them up now.
 
Stephen Foy
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Explain the difference between a syntax error and a Java Exception.

A syntax error is a violation of the programming language, e.g.: referring to invalid variables.
A java exception is an object which holds information about an error situation, If you implement code to deal with an exception then a crash will not occur. e.g.:

try {
// try something
} catch(IOException ex) {
//do something
}

2. What is the difference between checked and unchecked exceptions in java?

A checked exception describes a problem that will likely happen that the programmer cannot prevent. The java compiler will check for these and if you have not handled the exception in the code, it will generate a compiler error. You can do this by implementing a try/catch. Or you can throw it to the calling method and so on up until the java system, the java system will handle the exception by printing a trace of the methods that were visited before the exception occurred.

An unchecked exception will not be checked by the compiler, the programmer must anticipate these exceptions. And use an appropriate try/catch to catch the exception.

3. Describe static data and dynamic data. Which is more useful, and why?

Static data is declared in the code by the programmer, and dynamic data is declared at runtime. Dynamic data is useful as we can declare any value at run time, instead of a fixed value with static data, if we wanted to change the value we would have to go into the code and change it. For example to statically give an array of values we would have to go through all the array locations. With dynamic however we don�t have to, we can input the data ourselves, read it from a file.

Staticynamic:

array[1] = 1;for(int i = 1;i <= 3;i++)
array[2] = 1;array[i] = 1;
array[3] = 1;

4. Why do some methods use �void�in their header while others use a type e.g. String or int?

When we use a void header in a method we intend not to return any values, however when type String or int is used, we intend to return that type of value in the method. E.g:

public void someMethod( ) {
// do something here
}

public int someMethod(int number ) {
// do something here
return number
}

5. Why do some methods use �static�in their header while others do not?

A static method can be accessed outside the declared class.

6. What are formal parameters, and how are they different from actual parameters?

A formal parameter is declared/created in the method heading, and a actual parameter is created in the call to a method.
[ April 29, 2006: Message edited by: Stephen Foy ]
 
Jeroen T Wenting
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) technically correct, but not all the difference.
Hint: when do you get one, when the other.

2) wrong in general. While indeed the compiler won't check whether you handle a runtime exception that doesn't mean you should anticipate them.
Most often in fact you won't want to handle them at all because they indicate logic errors in your code which you want to be fatal and fix before shipping the application.

3) depends on your definition...

5) correct intention, incorrect wording. A static member can be accessed outside the context of any class instance, it still needs a class to exist.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!