Professional Documents
Culture Documents
com
Open Certification Plattform
http://www.JavaChamp.com
(2) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(3) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
Copyright
DISCLAIMER
All services and content of JavaChamp.com are provided under JavaChamp.com terms of use on an "as is" basis, without
warranty of any kind, either expressed or implied, including, without limitation, warranties that the provided services and
content are free of defects, merchantable, fit for a particular purpose or non-infringing. The entire risk as to the quality and
performance of the provided services and content is with you. In no event shall JavaChamp.com be liable for any damages
whatsoever arising out of or in connection with the use or performance of the services. Should any provided services and
content prove defective in any respect, you (not the initial developer, author or any other contributor) assume the cost of any
necessary servicing, repair or correction. This disclaimer of warranty constitutes an essential part of these "terms of use". No
use of any services and content of JavaChamp.com is authorized hereunder except under this disclaimer.
http://www.javachamp.com/public/termsOfUse.xhtml
This work is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 license.
http://creativecommons.org/licenses/by-nc-nd/3.0/legalcode
http://creativecommons.org/licenses/by-nc-nd/3.0/
According to the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 license You agree to the following:
You are free to share, copy, distribute and transmit the work under the following conditions:
(4) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
JavaChamp Competition
Competition Details
JavaChamp.com offers you the chance to win a 50$ Amazon Gift Card by contributing to JavaChamp.com question bank.
Competition description:
You can contribute questions in different IT subjects such as Java, Html, SQL, CSS, etc.
* To be able to participate in the competition you have to be a registered member in our community.
* Having a JavaChamp Public Profile is optional but will earn you some extra points in the competition final round.
How to qualify:
How to win:
the number of questions submitted but also with the quality and originality of questions.
Competition Prize:
The prize is a 50$ Amazon Gift Card which will be delivered to the winner by the appropriate means.
The winner's name will be posted in our website and will be marked accordingly in her/his public profile.
(5) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
Table of Contents
2. C Programming Language
- Basics
- Arithmetic operators
- Logical operators and Conditions
- Print out Statements
- Flow Control
- Inputs Reading
- Assignement
- Arrays
- Methods and Functions
- Identifiers and Variables
- Data Types
- Strings
(6) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(7) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1. Chapter: Java Programming Language
Chapter Description and Objectives
1. Strings
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(8) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.2. How to compare java objects?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(9) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.3. What are common methods between String and StringBuffer?
Select the common methods, which are defined for both type String and type StringBuffer ?
Check this Question online on JavaChamp.com: What are common methods between String and
StringBuffer?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(10) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.4. What is the difference between String and StringBuffer?
}
}
Check this Question online on JavaChamp.com: What is the difference between String and StringBuffer?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(11) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.5. Comparing String and StringBuffer in java
}
}
Check this Question online on JavaChamp.com: Comparing String and StringBuffer in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(12) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.6. Concatenating String and null
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(13) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.7. Comparing StringBuffer using equals in java
Check this Question online on JavaChamp.com: Comparing StringBuffer using equals in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(14) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.8. comparing null to String
String s1 = null;
String s2 = null;
if (s1 == s2)
System.out.print("A");
if (s1.equals(s2))
System.out.print("B");
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(15) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.9. Methods of java regex Pattern?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(16) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.10. Comparing Strings for equality in java
String a = "javachamp";
String b = "javachamp";
String c = new String("javachamp");
System.out.print(a==b);
System.out.print(a==c);
System.out.print(b.equals(c));
System.out.print(b.equals(a));
}
}
Check this Question online on JavaChamp.com: Comparing Strings for equality in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(17) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.11. how to split String in java?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(18) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.12. How to parse String in java?
import java.util.regex.Matcher;
import java.util.regex.Pattern;
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(19) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.13. How to use StringBuffer in java?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(20) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.14. How to use java StringBuffer?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(21) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.15. How to use java.util.Scanner?
import java.util.Scanner;
if (sc.hasNextBoolean())
System.out.print("Boolean");
if (sc.hasNextInt())
System.out.print("Int");
sc.next();
}
}
}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(22) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.16. What are java StringBuffer methods?
Check this Question online on JavaChamp.com: What are java StringBuffer methods?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(23) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(24) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
2. Constructors
Check this Question online on JavaChamp.com: Can java constructors be declared static?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(25) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.2.2. What are java constructors legal modifiers?
What are the legal modifiers which the constructor can be declared with?
Check this Question online on JavaChamp.com: What are java constructors legal modifiers?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(26) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.2.3. Can java constructors be declared final?
}
}
Check this Question online on JavaChamp.com: Can java constructors be declared final?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(27) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.2.4. Can java constructors be marked static?
Check this Question online on JavaChamp.com: Can java constructors be marked static?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(28) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.2.5. When can call super() in java constructors?
class Plant {
Plant() {
System.out.println("Plant created");
}
}
}
}
Check this Question online on JavaChamp.com: When can call super() in java constructors?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(29) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.2.6. How to call super() in java constructor?
import java.io.IOException;
class AirPlane {
public AirPlane() throws IOException {
System.out.print("AirPlane");
throw new IOException();
}
}
Check this Question online on JavaChamp.com: How to call super() in java constructor?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(30) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.2.7. How to call this() in java constructor?
The following code contains one compilation error, where could it be?
Tester() { } // line 1
static void Tester() { this(); } // line 2
Check this Question online on JavaChamp.com: How to call this() in java constructor?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(31) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(32) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
3. Inner class
1.3.1. How to access an outer class member from inside its inner class?
}
}
class Airplane {
String code = "11";
class BlackBox {
String code = "22";
}
}
Check this Question online on JavaChamp.com: How to access an outer class member from inside its inner
class?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(33) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.3.2. How to access a member of an outer class from inside its inner class?
}
}
class Airplane {
String code = "11";
class BlackBox {
String code = "22";
}
}
Check this Question online on JavaChamp.com: How to access a member of an outer class from inside its
inner class?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(34) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.3.3. How to instantiate an inner class inside main()?
// instantiation 1
Airplane airplane = new Airplane();
Airplane.BlackBox box1 = airplane.new BlackBox();
// instantiation 2
Airplane.BlackBox box2 = new Airplane().new BlackBox();
// instantiation 3
Airplane airplane3 = new Airplane();
BlackBox box3 = airplane3.new BlackBox();
}
}
class Airplane {
class BlackBox {
}
}
Check this Question online on JavaChamp.com: How to instantiate an inner class inside main()?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(35) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.3.4. How to instantiate an inner class?
// instantiation 1
Engine engine1 = new AirJet().new Engine();
// instantiation 2
AirJet.Engine engine2 = new AirJet().new Engine();
// instantiation 3
AirJet airjet = new AirJet();
Engine engine3 = airjet.new Engine();
}
class Engine{
}
}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(36) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.3.5. How to declare java inner class inside a method?
final int e = 1;
class FlyingEquation {
{
System.out.println(e);// line 1
System.out.println(speed);// line 2
}
}
}
}
Check this Question online on JavaChamp.com: How to declare java inner class inside a method?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(37) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.3.6. How java inner class access outer class?
What statement,inserted independently at // insert statement here, would produce output “Body” ?
class Heart {
String name = "Heart";
String getPName() {
// insert statement here
}
Check this Question online on JavaChamp.com: How java inner class access outer class?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(38) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(39) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
4. Flow Control
}
if (a > 5) {
break start;
}
}
}
Check this Question online on JavaChamp.com: How to write java labeled for loop?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(40) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.4.2. How to use break and continue in java for loop?
}
}
}
}
Check this Question online on JavaChamp.com: How to use break and continue in java for loop?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(41) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.4.3. How to use break and continue loop control commands in java?
}
}
}
}
Check this Question online on JavaChamp.com: How to use break and continue loop control commands in
java?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(42) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.4.4. How to use break and continue in java labeled for loop?
}
}
}
}
Check this Question online on JavaChamp.com: How to use break and continue in java labeled for loop?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(43) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.4.5. How to use break and continue in java loop?
Check this Question online on JavaChamp.com: How to use break and continue in java loop?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(44) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.4.6. How to use continue and break in java loop?
Check this Question online on JavaChamp.com: How to use continue and break in java loop?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(45) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.4.7. How to write java switch statement?
Check this Question online on JavaChamp.com: How to write java switch statement?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(46) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.4.8. do while loop syntax in java
do {
System.out.print("inside do");
} while (false);
while (false) {
System.out.print("inside while");
}
System.out.print("outside");
}
}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(47) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.4.9. Java switch statement syntax
case 5: {
System.out.println("match");
}
default: {
System.out.println("default");
}
}
}
}
}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(48) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.4.10. How to use java main method argument?
What is the result of running the following program given the command line:
Check this Question online on JavaChamp.com: How to use java main method argument?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(49) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.4.11. Ho to write If-statement in java?
Given the following code, which of if-statements declared is correctly written and causes no compilation error?
// stmt 1
if (x>0){}
// stmt 2
if (x=9){} else {}
// stmt 3
if (true){
} else if (x<0){
}
// stmt 4
if (true){
} else (x<0){
} else {
}
// stmt 5
if(true){
if (false){
}
else {
}
} else {
if (true){
}
}
}
}
(50) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(51) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.4.12. How to write do while statement in java?
Check this Question online on JavaChamp.com: How to write do while statement in java?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(52) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(53) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
5. Declarations and Access Control
static int x = 4;
public Tester() {
System.out.print(this.x); // line 4
Tester();
}
Check this Question online on JavaChamp.com: Can java static methods invoke this?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(54) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.5.2. What can java static methods make references to?
static int x = 4;
int y = 9;
public Tester() {
System.out.print(this.x); // line 7
printVariables();
}
Check this Question online on JavaChamp.com: What can java static methods make references to?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(55) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.5.3. How to access a class from another package in java?
package trunk1;
package trunk2;
import trunk1.Sheet;
Check this Question online on JavaChamp.com: How to access a class from another package in java?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(56) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.5.4. packages and access scope in java
You have three packages, trunk1,trunk2 and trunk3, What is the expected output for running file Tester?
package trunk1;
Account() { //line 3
System.out.println("Account");
}
}
package trunk2;
import trunk1.Account;
package trunk3;
import trunk1.Account;
import trunk2.CurrentAccount;
(57) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
Check this Question online on JavaChamp.com: packages and access scope in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(58) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.5.5. How to use java static members?
Check this Question online on JavaChamp.com: How to use java static members?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(59) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.5.6. How to access java class from another package?
Consider the following two classes declared and defined in two different packages, what can be added in class B
to form what considered a correct access to class A from main() method of class B?
package package.subPackage;
public class A { }
package anotherPackage;
// line 1
public class B {
public static void main(String[] args) {
// line 2
}
}
Check this Question online on JavaChamp.com: How to access java class from another package?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(60) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.5.7. types of relationships between java classes
interface Chewable {}
interface Eatable extends Chewable{}
class Vitamin{}
class Food implements Eatable { Vitamin[] vitamins;}
Check this Question online on JavaChamp.com: types of relationships between java classes
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(61) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.5.8. Can java constructor be private?
class Base {
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(62) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.5.9. what does final do in java?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(63) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.5.10. strictfp in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(64) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.5.11. strictfp modifier in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(65) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.5.12. class modifiers in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(66) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(67) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
6. Interfaces and Abstract Classes
Is the following declaration for interface Bendable correct and free of compilation error?
Check this Question online on JavaChamp.com: How to declare a class inside an interface in java?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(68) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.6.2. How to declare java interface?
Is the following declaration for interface Bendable correct and free of compilation error?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(69) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.6.3. What are java interface legal declaration rules?
Is the following declaration for interface Bendable correct and free of compilation error?
Check this Question online on JavaChamp.com: What are java interface legal declaration rules?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(70) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.6.4. How to extend java abstract class?
AirJet() {
super(); // line 14
}
void fly() {
System.out.print("Flying..");
}
}
Check this Question online on JavaChamp.com: How to extend java abstract class?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(71) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.6.5. Extending java abstract class
The following code contains a compilation error , what can be done to fix this error - independently?
void land() {
System.out.print("Landing..");
}
AirJet() {
super(); // line 13
}
void fly() {
System.out.print("Flying..");
}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(72) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.6.6. Rules of declaring java abstract Class
Check this Question online on JavaChamp.com: Rules of declaring java abstract Class
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(73) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.6.7. How to declare variables inside java interface?
int a = 0;
public int b = 1;
public static int c = 2;
public static transient d = 3;
public final int e = 3;
public static final int f = 3;
Check this Question online on JavaChamp.com: How to declare variables inside java interface?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(74) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.6.8. How to declare java abstract method?
Check this Question online on JavaChamp.com: How to declare java abstract method?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(75) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.6.9. What are the rules to implement an interface?
Considering the following declaration for interface Convertable, which of the following code segments will
compile?
int convertToInt();
char convertToChar();
}
• abstract class Digit implements Convertable {
int convertToInt() ;
char convertToChar();
}
• abstract class Digit implements Convertable {
(76) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
}
char convertToChar() {
return 0;
}
}
• interface Roundable extends Convertable {
int roundUp();
}
Check this Question online on JavaChamp.com: What are the rules to implement an interface?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(77) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.6.10. How to declare java abstract class?
Check this Question online on JavaChamp.com: How to declare java abstract class?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(78) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.6.11. how to write an interface?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(79) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.6.12. how to implement an interface in java?
To resolve the compilation error(s) in the following code we can (choose all what apply) :
interface Movable {
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(80) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(81) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
7. Exceptions
import java.io.IOException;
class Father {
public Father() throws IOException {
System.out.print("Father");
throw new IOException();
}
}
}
}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(82) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(83) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.7.2. How to handle java unchecked exceptions?
class Father {
public Father() throws RuntimeException {
System.out.print("Father");
throw new RuntimeException();
}
}
}
}
}
}
Check this Question online on JavaChamp.com: How to handle java unchecked exceptions?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(84) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.7.3. How to catch java exceptions?
import java.io.IOException;
class AirPlane {
public AirPlane() {
System.out.print("AirPlane");
}
}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(85) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.7.4. Can java constructors throw exceptions?
import java.io.IOException;
class AirPlane {
public AirPlane() throws IOException, RuntimeException {
System.out.println("AirPlane");
}
}
Check this Question online on JavaChamp.com: Can java constructors throw exceptions?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(86) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.7.5. How to usea try catch in java?
interface Foldable {
public void fold() throws Exception ;
Check this Question online on JavaChamp.com: How to usea try catch in java?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(87) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.7.6. How to declare try catch finally block in java?
System.out.print("1");
try {
System.out.print("2");
System.exit(0);
} finally {
System.out.print("3");
}
}
Check this Question online on JavaChamp.com: How to declare try catch finally block in java?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(88) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.7.7. try catch finally block in java
System.out.print("1");
try {
return;
} catch (Exception e) {
System.out.print("2");
} finally {
System.out.print("3");
}
System.out.print("4");
}
Check this Question online on JavaChamp.com: try catch finally block in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(89) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.7.8. How to write java try catch statement?
try {
throw new RuntimeException();
} catch (RuntimeException e) {
System.out.println("RuntimeException");
} catch (ArithmeticException e) {
System.out.println("ArithmeticException");
} catch (Exception e) {
System.out.println("Exception");
}
}
}
Check this Question online on JavaChamp.com: How to write java try catch statement?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(90) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.7.9. How to write java nested try catch?
try {
method();
} catch (Throwable e) {
try {
throw new Exception() ;
} catch (Exception ex) {
System.out.print("exception");
} finally {
System.out.print("finally");
}
}
}
}
Check this Question online on JavaChamp.com: How to write java nested try catch?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(91) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.7.10. How to write nested try catch in java?
try {
method();
} catch (Throwable e) {
try {
throw new Exception() ;
} catch (Exception ex) {
System.out.print("exception");
} finally {
System.out.print("finally");
}
}
}
}
Check this Question online on JavaChamp.com: How to write nested try catch in java?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(92) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.7.11. how to handle exceptions in java?
The following code contains compilation errors, what of the following possible solutions (made together) can be
done to remove these errors?
import java.io.File;
import java.text.DateFormat;
import java.util.Date;
call(); // line 11
DateFormat df = DateFormat.getDateInstance(); // line 12
Date parse = df.parse("12.11.2009"); // line 13
}
}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(93) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.7.12. How to handle exceptions using try/catch block?
Check this Question online on JavaChamp.com: How to handle exceptions using try/catch block?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(94) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.7.13. How to write try catch statement in java?
System.out.print("finally");
}
}
}
Check this Question online on JavaChamp.com: How to write try catch statement in java?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(95) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.7.14. When java NoClassDefFoundError is thrown?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(96) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(97) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
8. Inheritance
Are the following declarations correct, if you knew that they are in the same package?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(98) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.8.2. How to implement or extend in java?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(99) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.8.3. How to use java instanceof?
interface Colorable { }
}
}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(100) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.8.4. how to use instanceof java?
interface Colorable { }
class Individual { }
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(101) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.8.5. How to cast java variables?
Would the following code compile and if yes , what is the output?
interface Colorable {}
class Vehicle {}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(102) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.8.6. casting objects in java
Would the following code compile and if yes , what is the output?
interface Colorable {}
class Vehicle {}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(103) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.8.7. Order of constructor calls of java derived classes
class Category {
Category() {
System.out.print("Category_");
}
}
Check this Question online on JavaChamp.com: Order of constructor calls of java derived classes
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(104) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.8.8. using instanceof in java
interface Chewable {}
interface Eatable extends Chewable{}
class Food implements Chewable { }
class Meat extends Food {}
class Gum implements Chewable{}
}
}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(105) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.8.9. How to use instanceof in java?
interface Chewable {}
interface Eatable extends Chewable{}
class Food implements Eatable { }
class Meat extends Food {}
class Gum implements Chewable{}
}
}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(106) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.8.10. how to implement interface or extend class in java?
Check this Question online on JavaChamp.com: how to implement interface or extend class in java?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(107) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.8.11. How to write constructor for derived class in java?
class Base {
Check this Question online on JavaChamp.com: How to write constructor for derived class in java?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(108) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.8.12. Inheritance and constrcutors in java
class Base {
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(109) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.8.13. How to call this inside java constructor?
class Base {
Check this Question online on JavaChamp.com: How to call this inside java constructor?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(110) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.8.14. When java classCastException is thrown?
class Creature {
String getName() {
return "Creature";
}
}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(111) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.8.15. How to cast in java?
The following program fails to compile, where could possibly be the compilation error(s)?
class Creature {}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(112) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.8.16. Casting rules in java
class Creature {
void grow() {
}
}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(113) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.8.17. How to java cast?
What inserted, independently at // insert code here , will compile and run with no errors and exceptions?
class Creature {
void grow() {
}
}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(114) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.8.18. null and instanceof in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(115) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(116) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
9. Arrays
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(117) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.9.2. array size in java
}
}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(118) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.9.3. When ArrayIndexOutOfBoundsException is thrown?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(119) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.9.4. Array declaration in java
int[] a[];
int b[3];
int []c[];
int[] d[];
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(120) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.9.5. When java ArrayIndexOutOfBoundsException is thrown?
if (x <= 10)
System.out.println("javachamp");
}
}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(121) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(122) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
10. Operators
static int i ;
public Tester() {
i = 1;
}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(123) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.10.2. How to use java short circuit operators?
}
}
Check this Question online on JavaChamp.com: How to use java short circuit operators?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(124) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.10.3. How to use java conditional operators?
Check this Question online on JavaChamp.com: How to use java conditional operators?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(125) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.10.4. Short circuit vs non shortcircuit operators in java
}
}
Check this Question online on JavaChamp.com: Short circuit vs non shortcircuit operators in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(126) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.10.5. short circuit operators in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(127) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.10.6. Concatenating operands in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(128) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.10.7. Java Boolean Logical Operators
}
}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(129) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.10.8. short circuit logical operators in java
}
}
Check this Question online on JavaChamp.com: short circuit logical operators in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(130) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.10.9. using == in java
System.out.print(x == y);
System.out.print(x == z);
}
class Foo {}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(131) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.10.10. if condition in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(132) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.10.11. String and + operator in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(133) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.10.12. ++ and -- in java
x = 0;
y = 0;
x = 5 + ++y;
System.out.print(x + "" + y);
}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(134) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.10.13. short-circuit AND in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(135) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.10.14. short-circuit OR in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(136) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.10.15. & non-short-circuit AND in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(137) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.10.16. | non-short-circuit OR in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(138) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.10.17. Logical Operators ^ and ! in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(139) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(140) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
11. Variables and Methods
int x = 5, y;
Check this Question online on JavaChamp.com: Using java variable before initialization
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(141) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.11.2. How to write method main in java?
Check this Question online on JavaChamp.com: How to write method main in java?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(142) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.11.3. java class data members
static {
int x = 3;
}
static int x;
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(143) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.11.4. How to use java local variables?
Check this Question online on JavaChamp.com: How to use java local variables?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(144) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.11.5. Java local variables initialization
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(145) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.11.6. How to call java static method?
print(new Integer(3));
Check this Question online on JavaChamp.com: How to call java static method?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(146) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.11.7. how to declare valid java variable?
Check this Question online on JavaChamp.com: how to declare valid java variable?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(147) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.11.8. How to write a java bean?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(148) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.11.9. What is java local variables scope?
Check this Question online on JavaChamp.com: What is java local variables scope?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(149) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.11.10. How to pass variables in java?
int x = 12;
static void reset( Tester obj){
obj = null;
}
public static void main(String[] args) {
Tester o1 = new Tester();
reset(o1);
System.out.print(o1.x);
}
}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(150) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.11.11. How variables are passed in java?
int x = 12;
Check this Question online on JavaChamp.com: How variables are passed in java?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(151) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.11.12. How to use java final variable?
Check this Question online on JavaChamp.com: How to use java final variable?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(152) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(153) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
12. Wrappers and Autoboxing
System.out.print(sum1.equals(sum2)); //line 3
System.out.print(sum2.equals(sum1)); //line 4
System.out.print(sum1==sum2); //line 5
}
}
Check this Question online on JavaChamp.com: Iinvoking equals() on java primitive type
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(154) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.12.2. var-args vs autoboxing in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(155) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.12.3. How does java autoboxing work?
Given that Long and Integer extend Number, what is the result of compiling and running the following code?
Check this Question online on JavaChamp.com: How does java autoboxing work?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(156) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.12.4. How does autoboxing work in java?
Check this Question online on JavaChamp.com: How does autoboxing work in java?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(157) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.12.5. How to compare between java wrappers?
Given the following code fragment, what is true about the following System.out statements?
System.out.print(arr1[0][0] == 1);
System.out.print(arr2[0] == x);
System.out.print(x instanceof Integer);
System.out.print(arr1[1][0] > (Integer) arr2[0]);
}
Check this Question online on JavaChamp.com: How to compare between java wrappers?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(158) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(159) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
13. Garbage Collection
How many objects are eligible for garbage collection after executing line 7?
Object a = x;
x = y;
y = z;
z = null; //line 7
}
}
Check this Question online on JavaChamp.com: When java object is eligible for garbage collection?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(160) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.13.2. What makes java object eligible for garbage collection?
What can be inserted at // insert code here, to make object created at line 5 eligible for garbage collection?
Integer x = arr[0];
Check this Question online on JavaChamp.com: What makes java object eligible for garbage collection?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(161) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.13.3. when does an object become subject to garbage collection in java?
Check this Question online on JavaChamp.com: when does an object become subject to garbage collection
in java?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(162) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(163) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
14. Overriding and Overloading
class Type {
public Object getTypeName(){
return "Type";
}
}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(164) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.14.2. Can override java final method?
class Base {
public final int getNext(int i) {
return ++i;
}
}
Check this Question online on JavaChamp.com: Can override java final method?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(165) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.14.3. Overriding rules in java
class Creature {
Creature getIt() {
return this;
}
}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(166) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.14.4. var-args vs widening vs autoboxing in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(167) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.14.5. var-args vs autoboxing vs widening in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(168) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.14.6. How to override method with exceptions in java?
Which, inserted independently at //insert overridden call() here, will represent an overridden call() and compile
with no error?
class Base {
}
}
Check this Question online on JavaChamp.com: How to override method with exceptions in java?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(169) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.14.7. final parameters when overriding
class Base {
public void method(final int x) {
System.out.print("Base");
}
}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(170) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(171) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
15. Collections
import java.util.NavigableMap;
import java.util.TreeMap;
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(172) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.15.2. What does java headMap() do?
import java.util.NavigableMap;
import java.util.TreeMap;
Check this Question online on JavaChamp.com: What does java headMap() do?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(173) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.15.3. how to sort java Treeset?
import java.util.Arrays;
import java.util.Set;
import java.util.TreeSet;
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(174) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.15.4. how to override equals() in java?
What is the expected output after compiling and running the following code?
import java.util.HashSet;
import java.util.Set;
System.out.print(myFooSet.size());
}
}
class Foo {
Integer code;
Foo(Integer c) {
code = c;
}
(175) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(176) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.15.5. overriding equals() method in java
System.out.print(foo1.equals(foo2));
}
}
class Foo {
Integer code;
Foo(Integer c) {
code = c;
}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(177) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.15.6. inserting into a TreeSet in java
The following code will throw a runtime exception, which line causes the exception?
import java.util.HashSet;
import java.util.Set;
import java.util.TreeSet;
class Foo {}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(178) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.15.7. using binarySearch with an array in java
Check this Question online on JavaChamp.com: using binarySearch with an array in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(179) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.15.8. searching an array using binarySearch in java
Check this Question online on JavaChamp.com: searching an array using binarySearch in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(180) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.15.9. binarySearch in java
Integer[] arr = { 1, 2, 3 };
System.out.print(Arrays.binarySearch(arr, 1)); // line 1
System.out.print(Arrays.binarySearch(arr, "javachamp")); // line 2
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(181) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.15.10. How to implement Comparable in java
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(182) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(183) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.15.11. how to sort a collection in java?
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
(184) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
Check this Question online on JavaChamp.com: how to sort a collection in java?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(185) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.15.12. inserting into a HashSet in java
import java.util.HashSet;
import java.util.Set;
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(186) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(187) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.15.13. How the Set collection allows no duplicates in java ?
In this program, the set humans allows for objects of type Human with the same age to be inserted. What can be
done to make the set reject any Human object with value age equals to age value for an already inserted human
object?
import java.util.HashSet;
import java.util.Set;
class Human {
Integer age;
Check this Question online on JavaChamp.com: How the Set collection allows no duplicates in java ?
(188) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(189) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.15.14. TreeMap methods in java
import java.util.TreeMap;
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(190) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.15.15. ceilingKey in TreeMap in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(191) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.15.16. tailMap, headMap and subMap in java
import java.util.SortedMap;
import java.util.TreeMap;
Check this Question online on JavaChamp.com: tailMap, headMap and subMap in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(192) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.15.17. subSet in java
import java.util.SortedSet;
import java.util.TreeSet;
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(193) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.15.18. PriorityQueue methods in java
What can be inserted, independently, at line // insert code here to cause the program to print out : [3, 4, 7, 0]
import java.util.*;
System.out.println(queue);
}
}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(194) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.15.19. inserting into a non generic TreeSet in java
import java.util.*;
}
}
Check this Question online on JavaChamp.com: inserting into a non generic TreeSet in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(195) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.15.20. equals and hashCode contract in java
Based on equals() and hashCode() contract in java, which of the following is true?
Check this Question online on JavaChamp.com: equals and hashCode contract in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(196) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.15.21. asList in java
import java.util.*;
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(197) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(198) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
16. Generics
import java.util.ArrayList;
import java.util.List;
}
}
Check this Question online on JavaChamp.com: How to declare instantiate java generic collection?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(199) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.16.2. How to add to java generic collection?
import java.util.ArrayList;
import java.util.List;
interface chewable {}
Check this Question online on JavaChamp.com: How to add to java generic collection?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(200) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.16.3. How to declare java generic collection?
import java.util.ArrayList;
import java.util.List;
interface chewable {}
Check this Question online on JavaChamp.com: How to declare java generic collection?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(201) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.16.4. java generic collection rules?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(202) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.16.5. When cannot add to a generic collection?
import java.util.ArrayList;
import java.util.List;
interface Chewable {}
class Meat implements Chewable {}
list1.add(meat); // Line 17
list2.add(meat); // Line 19
}
}
Check this Question online on JavaChamp.com: When cannot add to a generic collection?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(203) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.16.6. Proper instantiation of java generic collection
import java.util.ArrayList;
import java.util.List;
interface Chewable {}
class Meat implements Chewable {}
public static List<? extends Chewable> printSize(List<? extends Chewable> list) { // Line 10
System.out.println(list.size());
return list;
}
public static void main(String[] args) {
}
}
Check this Question online on JavaChamp.com: Proper instantiation of java generic collection
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(204) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.16.7. When were Generics first introduced in Java?
Check this Question online on JavaChamp.com: When were Generics first introduced in Java?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(205) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.16.8. how to sort a generic collection?
What is the expected output of compiling and running the following code?
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Collections.sort(myFooList);
System.out.print(myFooList.get(0).code);
}
}
Foo(String c) {
code = c;
}
int compareTo(Foo f) {
return this.code.compareTo(f.code);
}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(206) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.16.9. inserting into a non-generic collection in java
What is the expected output of compiling and running the following code?
import java.util.ArrayList;
import java.util.List;
list.add("Hello");
Foo f = new Foo();
list.add(f);
f = list.get(1);
System.out.print(list.get(0) + "-" + f);
}
}
class Foo {
public String toString() {
return "Foo";
}
}
Check this Question online on JavaChamp.com: inserting into a non-generic collection in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(207) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.16.10. generic collection as return type in java
Considering that all needed imports are there, what, inserted independently at line 1, will compile? (choose all
correct answers)
class A {}
class B extends A{}
class C extends B{}
Check this Question online on JavaChamp.com: generic collection as return type in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(208) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.16.11. generic methods in java
import java.util.*;
class B {
}
class C extends B {
}
Queue<C> q1;
PriorityQueue<C> q2;
q1 = ring(list1); // line1
q1 = ring(list2); // line2
q2 = ring(list1); // line3
q2 = ring(list2); // line4
}
}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(209) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.16.12. how to declare a generic collection in java?
How can this program be modified to make use of appropriate genertic types? choose 3 answers (one
modification for each line)
import java.util.*;
}
}
Check this Question online on JavaChamp.com: how to declare a generic collection in java?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(210) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.16.13. how to declare a generic Map in java?
Given the following incomplete program, based on the given put statements in map, what is considered a correct
declaration and instantiation for map ?
import java.util.*;
}
}
Check this Question online on JavaChamp.com: how to declare a generic Map in java?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(211) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(212) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
17. Formatting
Check this Question online on JavaChamp.com: writing java printf or format statement
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(213) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.17.2. java classes instantiated using factory method
Check this Question online on JavaChamp.com: java classes instantiated using factory method
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(214) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(215) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
18. I/O
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(216) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.18.2. How to create file in java?
At what line in the following program the file “data.txt” will be created in the file system?
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(217) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.18.3. What java exceptions thrown by File?
Given the following code segment enclosed within a try/catch block, what is the proper Exception type to catch
causing no compilation error?
try {
File file = new File("file.dat");
file.createNewFile();
} catch (
// INSERT EXCEPTION TYPE
e) {
e.printStackTrace();
}
Check this Question online on JavaChamp.com: What java exceptions thrown by File?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(218) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.18.4. How to instantiate java BufferedWriter?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(219) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(220) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
19. Threads
int code = 9;
Check this Question online on JavaChamp.com: How java thread start running?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(221) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.19.2. When java IllegalMonitorStateException is thrown?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(222) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.19.3. Can java thread invoke start more than once?
new Thread(thread).start();
new Thread(thread).start();
}
}
Check this Question online on JavaChamp.com: Can java thread invoke start more than once?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(223) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.19.4. When java IllegalThreadStateException is thrown?
What could be a part of the output of compiling and running the following code?
}
}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(224) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.19.5. which thread methods are static?
Check this Question online on JavaChamp.com: which thread methods are static?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(225) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.19.6. which methods are defined in calss object?
Check this Question online on JavaChamp.com: which methods are defined in calss object?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(226) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.19.7. when to override thread method run()?
When a class implements interface Runnable, it must provide implementation for method start():
Check this Question online on JavaChamp.com: when to override thread method run()?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(227) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.19.8. when a thread can call wait()?
A thread that calls the wait() method of an object, must owns the lock of the object.
Check this Question online on JavaChamp.com: when a thread can call wait()?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(228) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.19.9. how can a thread own the lock of an object?
Check this Question online on JavaChamp.com: how can a thread own the lock of an object?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(229) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.19.10. how to instantiate a thread object?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(230) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.19.11. How to create a Thread object?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(231) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.19.12. Create a thread by implementing Runnable
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(232) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.19.13. instatiate a thread by implementing Runnable interface
How many times the statement "we are painting" would be printed in this program?
}
}
Check this Question online on JavaChamp.com: instatiate a thread by implementing Runnable interface
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(233) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.19.14. starting many threads together in java
What is the possible output of compiling and running the following code?
request1.start();
request2.start();
}
}
Check this Question online on JavaChamp.com: starting many threads together in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(234) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.19.15. instatiate a thread by implementing Runnable in java
Check this Question online on JavaChamp.com: instatiate a thread by implementing Runnable in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(235) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.19.16. handling a checked exception
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(236) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.19.17. running a thread in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(237) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.19.18. synchronized static method and threads in java
What is the possible output of running this program once as it is and once by marking swim() synchronized?
}
public static void main(String[] args) {
new Thread(new Swimmer("Tom")).start();
new Thread(new Swimmer("Hanks")).start();
}
}
Check this Question online on JavaChamp.com: synchronized static method and threads in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(238) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.19.19. synchronized method and threads in java
What are the possible outputs of running this program once as it is, and second with marking swim()
synchronized?
}
public static void main(String[] args) {
new Thread(new Swimmer("Tom")).start();
new Thread(new Swimmer("Hanks")).start();
}
}
Check this Question online on JavaChamp.com: synchronized method and threads in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(239) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.19.20. synchronized method in java
What are the possible outputs of running this program once as it is, and second with marking swimIn()
synchronized?
pool.swimIn(name);
(240) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(241) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.19.21. how to synchronize a method in java
What is the possible result of compiling and running the following code?
pool.swimIn(name);
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(242) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(243) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.19.22. thread and synchronized method in java
What is the possible result of compiling and running the following code?
Check this Question online on JavaChamp.com: thread and synchronized method in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(244) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.19.23. synchronized non static method in java
What is the possible result of compiling and running the following code?
Check this Question online on JavaChamp.com: synchronized non static method in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(245) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.19.24. thread join java
What is ture?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(246) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.19.25. join thread in java
What is true?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(247) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.19.26. run vs start in threads in java
What are the possible results of compiling and running the following code?
int id;
Test(int id) {
this.id = id;
}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(248) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.19.27. sleep in thread in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(249) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.19.28. thread in java
What are the possible results of compiling and running the following code?
int id;
Test(int id) {
this.id = id;
start();
}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(250) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.19.29. using wait and sleep in threads in java
What are the possible results of compiling and running the following code?
};
t2.start();
new Thread(t1).start();
}
Check this Question online on JavaChamp.com: using wait and sleep in threads in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(251) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(252) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.19.30. using sleep and wait in thread in java
What is the possible results of compiling and running the following code?
};
Check this Question online on JavaChamp.com: using sleep and wait in thread in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(253) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(254) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.19.31. synchronizing and mutlithreading in java
The idea of this program is to allow two workers to build a wall (which consists of bricks and cement) , given the
following code, what necessarily modifications are needed to guarantee that the two workers will have a chance to
work and the wall will be built by alternating between bricks and cement (brickcementbrickcement...) ? (choose all
what apply)
Worker(Contract contract) {
this.contract = contract;
}
(255) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
Please choose all the answers that apply:
• synchronize putBrick()
• synchronize putCementLayer()
• synchronize work()
• add Thread.sleep() after putBrick() in work() method
• synchronize isWallDone()
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(256) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(257) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
20. Enums
enum Status {
Published(1), Rejected(2); // Line 2
int index; // Line 3
Status(int i) { index = i; }
int getIndex(){return index;} // Line 5
}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(258) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.20.2. Where java enum can be defined?
Check this Question online on JavaChamp.com: Where java enum can be defined?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(259) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.20.3. comparing enums in java
enum BookStatus {
PUBLISHED, DRAFT
}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(260) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(261) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
21. Data Types
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(262) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.21.2. float data type in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(263) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.21.3. Data types in java
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(264) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(265) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
22. Static and init blocks
1.22.1. In what order static and init blocks get called in java?
class Bird {
static {
System.out.print("static1 ");
}
{
System.out.print("init3 ");
}
public Bird() {
System.out.print("Bird ");
}
static {
System.out.print("static2 ");
}
Falcon(){
System.out.print("Falcon ");
}
public static void main(String[] args) {
System.out.print("main ");
new Falcon();
}
}
Check this Question online on JavaChamp.com: In what order static and init blocks get called in java?
(266) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(267) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(268) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
23. Serialization
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
class Base {
int code = 99;
Base() {
code = 77;
}
}
try {
FileOutputStream fos = new FileOutputStream("data.txt");
ObjectOutputStream os = new ObjectOutputStream(fos);
os.writeObject(derived1);
os.close();
FileInputStream fis = new FileInputStream("data.txt");
ObjectInputStream is = new ObjectInputStream(fis);
Derived derived2 = (Derived) is.readObject();
System.out.print(derived2.code);
is.close();
} catch (Exception x) {
}
(269) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
Check this Question online on JavaChamp.com: How to combine inheritance and serialization in java?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(270) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.23.2. How to serialize java class?
Given the following two classes (Address and Account), what may happen if you attempt to serialize an instance
of Account?
class Address{}
class Account implements Serializable {Address address;}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(271) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.23.3. What variables cannot be serialized in java?
Check this Question online on JavaChamp.com: What variables cannot be serialized in java?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(272) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.23.4. What cannot be serialized in java?
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
transient int x = 5;
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(273) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(274) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1. Chapter: C Programming Language
Chapter Description and Objectives
1. Basics
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(275) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.2. c language
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(276) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.3. how to include in C?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(277) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.4. How to write comments in C language?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(278) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.5. main function in C
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(279) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.6. how to include a header in C?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(280) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.7. include in C
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(281) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(282) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
2. Arithmetic operators
int c = 19 % 4;
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(283) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.2.2. How to square a value in C?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(284) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.2.3. How to increment in C?
int x = 3, y = 5, z;
z = ++x + ++y;
printf(“%d”,z);
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(285) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.2.4. How to increment int in C?
int x = 3, y = 5, z;
z = x + ++y;
printf(“%d”,z);
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(286) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.2.5. How incrementation works in C?
int x = 3, y = 5, z ;
z = x++ + ++y;
printf(“%d”,z);
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(287) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.2.6. How sqrt method works in C?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(288) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.2.7. arithmetic operators in C
int x = 9 , y = 2 , z = x / y;
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(289) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.2.8. post increment in C
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(290) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.2.9. write method in C
choose the proper function to compute the cubic value of any input integer n:
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(291) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.2.10. C arithmetic operators
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(292) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.2.11. decrementation in C
int a = 1, b = 2, c;
c = a-- + b--;
printf(“%d”,c);
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(293) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.2.12. remainder operator in C
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(294) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(295) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
3. Logical operators and Conditions
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(296) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.3.2. How to write if statement in C?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(297) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.3.3. How to evaluate conditions in C?
What is the result of the condition ( a && b ) given the following declaration :
int a = 3 , b = 1 ;
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(298) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.3.4. How to evaluate C conditions?
int x = 7;
if ( x = 3 ) printf( “%d“ , x);
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(299) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.3.5. How to write C if statement?
if ( 16 = m ) printf(“m is 16”);
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(300) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.3.6. bit-wise AND operator in C
the & operator in the Boolean condition if( (x>5) & ( y < 9 ) ) …
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(301) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.3.7. logical AND operator in C
int x = 1 , y = 2 ;
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(302) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.3.8. bit-wise AND C operator
int x = 1 , y = 2 ;
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(303) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.3.9. how conditions evaluated in C
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(304) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.3.10. conditional operator in Java
char c = 'c';
String result = (c > 'C') ? "c is greater than C " : "c is smaller than C";
System.out.print(result);
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(305) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(306) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
4. Print out Statements
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(307) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.4.2. How to print out ASCII in c?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(308) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.4.3. How to print out a character in C?
To print character a:
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(309) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.4.4. How to print out a String in C?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(310) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.4.5. print int in C
int x = 123;
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(311) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.4.6. printf float in C
what is the best choice to print the value of variable y where:float y = 2.34;
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(312) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.4.7. how to print double in C?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(313) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(314) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
5. Flow Control
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(315) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.5.2. how to write while loop in C?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(316) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.5.3. using for loop in C
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(317) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.5.4. while loop in C
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(318) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.5.5. how to write for loop in C?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(319) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.5.6. infinite loop in C
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(320) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.5.7. infinite while loop in C
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(321) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.5.8. how to write switch in C?
switch(2) {
case 1: printf(“One”);break;
case 2: printf(“Two”);
case 3: printf(“Three”);break;
}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(322) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.5.9. how switch works in C?
switch(2) {
case 1: printf(“One”);break;
case 2: printf(“Two”);break;
case 3: printf(“Three”);break;
}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(323) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.5.10. how to write switch statement in C?
switch(476) {
case 1: printf(“One”);break;
case 2: printf(“Two”);break;
default: printf(“Default”);break;
}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(324) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(325) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
6. Inputs Reading
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(326) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.6.2. How to read inputs into an array in C?
To get a statement from the user input in the array char s[100]:
Check this Question online on JavaChamp.com: How to read inputs into an array in C?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(327) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.6.3. How to write C scanf?
scanf(“%d”, &time);
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(328) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.6.4. read char in C
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(329) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(330) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
7. Assignement
Check this Question online on JavaChamp.com: How to cenvert between char and int in C?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(331) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(332) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
8. Arrays
Check this Question online on JavaChamp.com: How to declare and initialize character array in C?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(333) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.8.2. how to declare C arrays?
float values(200) = ( 1 , 2 , 3 , 4 );
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(334) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.8.3. declare char array in C
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(335) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.8.4. Arrays declaration in C
float values(200) = ( 1 , 2 , 3 , 4 );
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(336) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(337) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
9. Methods and Functions
main(){
int x = 5;
change(x);
printf(“%d”,x);
}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(338) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.9.2. How to write and call method?
main(){
int x = 5 , y = 3;
printf(“%d”, sum(x,y));
}
Check this Question online on JavaChamp.com: How to write and call method?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(339) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.9.3. How to write C method?
return x*y;
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(340) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.9.4. how to print int in C?
main(){
int x;
printf(“%d”,x);
}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(341) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.9.5. pass by value in C?
main(){
int x = 5;
change(x);
printf(“%d”,x);
}
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(342) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.9.6. return value in c method?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(343) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(344) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
10. Identifiers and Variables
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(345) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.10.2. how to declare a valid variable in C?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(346) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.10.3. how to declare C legal iedntifier?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(347) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.10.4. How to declare C valid variable?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(348) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.10.5. variable role in C
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(349) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.10.6. variable declaration in C
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(350) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.10.7. how to define a constant in C?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(351) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(352) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
11. Data Types
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(353) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.11.2. Data types in C
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(354) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.11.3. float storage size in C
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(355) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.11.4. char storage size in C
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(356) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.11.5. int storage size in C
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(357) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.11.6. how to assign int into char in C?
Check this Question online on JavaChamp.com: how to assign int into char in C?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(358) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.11.7. max value in number system
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(359) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.11.8. LSB in C
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(360) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.11.9. MSB in C
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(361) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(362) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
12. Strings
Check this Question online on JavaChamp.com: How to copy a string into another in C?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(363) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.12.2. how to concatenate strings in C?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(364) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(365) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1. Chapter: Assembly Programming Language
Chapter Description and Objectives
1. Basics
The Debug program is a small MS-DOS utility and is usually useful in:
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(366) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.2. Who writes ROM BIOS contents ?
Check this Question online on JavaChamp.com: Who writes ROM BIOS contents ?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(367) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.3. What does ROM BIOS contain?
Check this Question online on JavaChamp.com: What does ROM BIOS contain?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(368) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.4. What is first executed when starting the computer?
Check this Question online on JavaChamp.com: What is first executed when starting the computer?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(369) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.5. Memory segments can start every?
Check this Question online on JavaChamp.com: Memory segments can start every?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(370) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.6. what was max memory space by 8086 processor?
Check this Question online on JavaChamp.com: what was max memory space by 8086 processor?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(371) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.7. what was max memory space in 8086 processor?
The limitation on The maximum memory space addressable by 8086 processor because:
Check this Question online on JavaChamp.com: what was max memory space in 8086 processor?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(372) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.8. What is maximum memory proportional to?
Check this Question online on JavaChamp.com: What is maximum memory proportional to?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(373) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.9. What is the mapping between physical address and logical address?
The mapping between the physical address and logical address (Segment:Offset) is:
Check this Question online on JavaChamp.com: What is the mapping between physical address and logical
address?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(374) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.10. What does the sign flag do?
Check this Question online on JavaChamp.com: What does the sign flag do?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(375) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.11. How can a physical address be represented?
Check this Question online on JavaChamp.com: How can a physical address be represented?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(376) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.12. Hoe overflow by addition is handled?
If you add positive number plus negative number the over flow flag will be set if:
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(377) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.13. How the processor compute the address of the next instruction?
Check this Question online on JavaChamp.com: How the processor compute the address of the next
instruction?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(378) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.14. What is cold boot?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(379) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.15. function service number (4Ch)
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(380) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.16. The assembly directive
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(381) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.17. What is the value of AL register when using interrupt (INT 21h), service number (4Ch)?
The value in AL register when using interrupt (INT 21h), service number (4Ch) is:
Check this Question online on JavaChamp.com: What is the value of AL register when using interrupt (INT
21h), service number (4Ch)?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(382) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.18. What is the difference between PSP and header block?
Check this Question online on JavaChamp.com: What is the difference between PSP and header block?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(383) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.19. how to initialize DS register?
You know that the data segment base address = 1234, so :how to initialize DS register?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(384) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.20. how to initialize the IP register?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(385) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.21. How to move bytes from address to another?
You want to move two bytes from address 100 to 200, so what is the proper instruction:
Check this Question online on JavaChamp.com: How to move bytes from address to another?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(386) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.22. What is Register addressing mode?
What is the memory addressing mode of the first operand in the instruction MOV BX,1234:
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(387) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.23. what is Indirect addressing mode?
What is the memory addressing mode of the first operand in the instruction MOV [BX],1234:
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(388) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.24. AX register
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(389) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.25. How to set only odd numbered bits in AX register?
You want to set only odd numbered bits in AX register, so what is the proper instruction:
Check this Question online on JavaChamp.com: How to set only odd numbered bits in AX register?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(390) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.26. how to complement only odd numbered bits in AX register?
You want to complement only odd numbered bits in AX register, so what is the proper instruction:
Check this Question online on JavaChamp.com: how to complement only odd numbered bits in AX
register?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(391) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.27. AX register in assembly
What is the value of AX register after the following instruction, assume Mark stored at offset 1000
Mark DW 123
Mov AX,Mark
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(392) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.28. AX register assembly
What is the value of AX register after the following instructions, assume Mark at offset 1000
Mark DW 123
LEA AX,Mark
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(393) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.29. What is the value of over flow flag after SUB AX AX
What is the value of over flow (O) flag after the instruction: SUB AX,AX
Check this Question online on JavaChamp.com: What is the value of over flow flag after SUB AX AX
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(394) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.30. What is the value of Zero flag after SUB AX AX
What is the value of Zero (Z) flag after the instruction: SUB AX,AX
Check this Question online on JavaChamp.com: What is the value of Zero flag after SUB AX AX
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(395) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.31. From where operating system is loaded?
The operating system (DOS / Windows) generally loaded (system boot) from:
Check this Question online on JavaChamp.com: From where operating system is loaded?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(396) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.32. When will auxiliary flag be set?
Check this Question online on JavaChamp.com: When will auxiliary flag be set?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(397) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.33. What are the operating system functions?
Check this Question online on JavaChamp.com: What are the operating system functions?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(398) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.34. How many segments .COM programs in RAM use?
Check this Question online on JavaChamp.com: How many segments .COM programs in RAM use?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(399) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.35. Who generates PSP for .COM programs?
Check this Question online on JavaChamp.com: Who generates PSP for .COM programs?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(400) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.36. Why the limitation on The maximum memory space by 8086 processor?
The limitation on The maximum memory space addressable by 8086 processor because:
Check this Question online on JavaChamp.com: Why the limitation on The maximum memory space by
8086 processor?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(401) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.37. What is the multiple Segment Offset representations for a unique physical address?
Check this Question online on JavaChamp.com: What is the multiple Segment Offset representations for a
unique physical address?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(402) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.38. What is assembly directive?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(403) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.39. How to display the contents of 100 bytes?
To display the contents of 100 bytes starting at physical address 00000 using the debug:
Check this Question online on JavaChamp.com: How to display the contents of 100 bytes?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(404) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.40. What is the memory addressing mode?
What is the memory-addressing mode of the first operand in the MOV instruction?
Check this Question online on JavaChamp.com: What is the memory addressing mode?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(405) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.41. debug command -E
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(406) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.42. debug command U
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(407) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.43. max size of .COM program
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(408) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.44. Command DB
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(409) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.45. How to increment a register?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(410) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.46. how many segment you can use for .com program?
To write assembly program that generates .COM program, how many segment you can use:
Check this Question online on JavaChamp.com: how many segment you can use for .com program?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(411) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.47. Stack segment in .COM program
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(412) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.48. instruction AND AH
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(413) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.49. MOV and CMP AX register
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(414) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.50. Memory segments
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(415) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.51. How many bytes in one word?
Check this Question online on JavaChamp.com: How many bytes in one word?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(416) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.52. How many bits in one byte?
Check this Question online on JavaChamp.com: How many bits in one byte?
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(417) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.53. logical operator AND
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(418) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.54. cpu Accumulator register
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(419) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.55. logical operator OR
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(420) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.56. logical operator XOR
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(421) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.57. length of the 8088 processor physical address
Check this Question online on JavaChamp.com: length of the 8088 processor physical address
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(422) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.58. logical operator OR in assembly
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(423) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.59. logical operator XOR in assembly
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(424) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.60. double word
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(425) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.61. bits in double word
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(426) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.62. Counter register
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(427) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.63. instructions performed in Counter register
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(428) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
1.1.64. Index registers
JavaChamp.com Competition: Win 50$ Amazon Gift Card Check the competition details and be the Champ!
(429) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved
(430) JavaChamp.com SCJP Mock Exams - Copyright 2009 all rights reserved