COMPUTER SCIENCE JAVA QUESTIONS AND
ANSWERS
keywords - ANSWER class, while and if are.
primitive types - ANSWER which are simple values stored directly in the
memory location
reference types - ANSWER which store addresses of objects stored
somewhere else in memory
static - ANSWER methods not associated with any object
instance - ANSWER methods are part of objects and can only be called
through an object
What are the two general ways of accessing a Java array? - ANSWER direct
access and sequential access
direct access - ANSWER accessing an arbitrary location
sequential access - ANSWER going through the entire array
compiler/syntax errors - ANSWER prevent program from being compiled
properly,
, forgetting semicolon or braces
logic errors - ANSWER are problems with what the code actually does, like
forgetting braces around else, so the code doesn't know what to do with else
Data hiding - ANSWER when an object hides its internal data from code
outside the class that the object
//is an instance of. Only the class can access its own methods. Make fields
private and methods public
data abstraction - ANSWER using a class without knowing its implementation
Details
differences between array and arraylist - ANSWER - Array is a fixed length
data structure
- arraylist- You can not change length of Array once created in Java but
ArrayList re-size itself when gets full depending upon capacity and load factor.
-moreover, one big difference between ArrayList and Array is that you can't
store primitives in ArrayList it only can contain Objects while Array in java can
hold primitives as well as Objects
infinite loops - ANSWER -kind of a loop which doesn't get over, that means
its test condition will always true because nothing is being done inside the body
to affect condition.
ANSWERS
keywords - ANSWER class, while and if are.
primitive types - ANSWER which are simple values stored directly in the
memory location
reference types - ANSWER which store addresses of objects stored
somewhere else in memory
static - ANSWER methods not associated with any object
instance - ANSWER methods are part of objects and can only be called
through an object
What are the two general ways of accessing a Java array? - ANSWER direct
access and sequential access
direct access - ANSWER accessing an arbitrary location
sequential access - ANSWER going through the entire array
compiler/syntax errors - ANSWER prevent program from being compiled
properly,
, forgetting semicolon or braces
logic errors - ANSWER are problems with what the code actually does, like
forgetting braces around else, so the code doesn't know what to do with else
Data hiding - ANSWER when an object hides its internal data from code
outside the class that the object
//is an instance of. Only the class can access its own methods. Make fields
private and methods public
data abstraction - ANSWER using a class without knowing its implementation
Details
differences between array and arraylist - ANSWER - Array is a fixed length
data structure
- arraylist- You can not change length of Array once created in Java but
ArrayList re-size itself when gets full depending upon capacity and load factor.
-moreover, one big difference between ArrayList and Array is that you can't
store primitives in ArrayList it only can contain Objects while Array in java can
hold primitives as well as Objects
infinite loops - ANSWER -kind of a loop which doesn't get over, that means
its test condition will always true because nothing is being done inside the body
to affect condition.