JavaBeat
SCJP 5.0 Home New to SCJP? Objectives Articles Mock Exams Tutorials Resources SiteMap & Links Forums  

SCJP 5.0 Questions
01. MockExam - 01
02. MockExam - 02
03. MockExam - 03
04. AutoBoxing - 1 (10 questions)
05. AutoBoxing - 2 (10 questions)
06. Generics 1 - 6 Questions
07. Generics 2 - 7 Questions
08. Generics 3 - 10 Questions
09. Generics 4 - 10 Questions
10. Generics 5 - 10 Questions
11. Generics 6 - 10 Questions
12. Enum 1 - 10 Questions
13. Enums 2 - 10 Questions
14. Enums 3 - 15 Questions
15. Var Args 1 - 10 Questions
16. Var Args 2 - 10 Questions
17. SCJP 5.0 Mock Questions -1
18. Declaration,Access Control-1
19.Java File IO Package - 1
20.Java File IO Package - 2
21.Language Features - 1
22.New Api's - 1 (10 questions)
23.New Api's - 2 (12 questions)
24.Objective - 1 (20 questions)
25.Objective - 2 (10 questions)
26.Objective - 3 (10 questions)
27.Objective - 4 (10 questions)
28.Objective - 5 (10 questions)
29.Objective - 6 (10 questions)
30.Objective - 7 (10 questions)
Subscribe to SCJP 5.0 Group

1) Ans : 1->compile time error
Instance variable empid has private access in class Employee
It can be access only within the class Employee and using its member function
since class javabeat11 is trying to access instance variable empid we will get compile time error

2)ans : 4
abstract keyword can be applied to class,interface or method
abstract keyword can't be applied to instance variable

3)ans : 4-> main
main is not a keyword in java.
main is just a method name
we can have a instance variable with name main in class
goto is keyword in java but rarely used in java

4)ans : 4-> struct
struct is not a keyword in java
struct is keyword in c++
Both throw and throws are keyword in java

5)Ans : 1->compile time error
Even though the instance variable of class Employee is public but the class access level is default
The Employee Class will be accessible only in the package EMPone.
class JavaBeat15 is in different package therefore it will not be able to access Employee class
As a result we get a compile time error.

6)Ans : 1->compile time error
The instance variable of class Employee is public and the class access level is also public
The Employee Class and its instance variable will be accesible anywhere
However we need to import the class Employee if it is to be used outside the package EMPone by using import statement :import EMPone.Employee;
In the above program import statement is missing due to which we get compile time error.

7)ans 1: Compile time error
The only modifier applicable to local variable is final
In the above program local variable x in method main is applied private modifier
As a result we get compile time error

8)Ans : 1->compile time error
The instance variable age of class Employee is protected and the class access level is also public
The protected variable are accessible in the same package and subclass in different package
Since JavaBeat18 is not subclass of class Employee and not in the same package it will not be able to access instance variable age of class Employee

9) Ans 2 ->false
interface variable are public,static and final by default. They are constant
we cannot change the value of Depid
The error is produced at line x.Depid=16 since we are trying to change the value of Depid

10)Ans :3
The variable count of class Employee is protected and the class access level is also public
The protected variable are accessible in the same package and subclass in different package
Since JavaBeat20 is subclass of class Employee,the code will compile fine
when instance of class Employee is created,variable count get incremented
Variable count is a static variable so it will be shared by all Employee instance.
Here count is externally initialzed to 10
Therefore final value of count is 10.


JavaBeat Website (2004-2008), India
javabeat | about us | useful resources
Copyright (2004 - 2008), JavaBeat