SlideShare a Scribd company logo
1 of 11
OCJP
www.javaexpert.co.in
Q. class Foo {
static void alpha() { /*code here */ }
void beta() { /*code here */ }
}
A. Foo.beta() is a valid invocation of beta().
B. Foo.alpha() is a valid invocation of alpha().
C. Method beta() can directly call method alpha().
D. Method alpha() can directly call method beta().
OCJP
www.javaexpert.co.in
Q. public class demo {
static public void main(String [] yahoo) {
for(int x = 1; x < yahoo.length; x++) {
System.out.print(yahoo[x] + " "); }
}
and the command line invocation:
java demo a b c
Output is : -
A. b c
B. a b c
C. Compilation fails.
D. An exception is thrown at runtime.
OCJP
www.javaexpert.co.in
Q. public class Yippee {
public static void main(String [] args) {
for(int x = 1; x < args.length; x++) {
System.out.print(args[x] + " "); }}}
From command line
java Yippee
java Yippee 1 2 3 4
A. No output 1 2 3 4
B. No output 2 3 4
C. An exception is thrown at runtime. 2 3 4
D. An exception is thrown at runtime. 1 2 3 4
OCJP
www.javaexpert.co.in
Q. package utils;
public class Repetition {
public static String twice(String s) { return s + s; } }
and given another class Demo:// insert code here
public class Demo {
public static void main(String[] args) {
System.out.println(twice("pizza"));}}
Which code should be inserted at line 1 of Demo.java to compile and run Demo to print
"pizzapizza"?
A. import utils.*;
B. static import utils.*;
C. import utils.Repetition.*;
D. static import utils.Repetition.*;
E. import utils.Repetition.twice();
F. import static utils.Repetition.twice;
G. static import utils.Repetition.twice;
OCJP
www.javaexpert.co.in
Q. A JavaBeans component has the following field:
private boolean enabled;
Which two pairs of method declarations follow the JavaBeans standard for
accessing this field? (select any two).
A. public void setEnabled( boolean enabled )
public boolean getEnabled()
B. public void setEnabled( boolean enabled )
public void isEnabled()
C. public void setEnabled( boolean enabled )
public boolean isEnabled()
D. public boolean setEnabled( boolean enabled )
public boolean getEnabled()
OCJP
www.javaexpert.co.in
Q. package util;
public class BitUtils {
public static void process(byte[]) { /* more code here */ }}
package app;
public class SomeApp {
public static void main(String[] args) {
byte[] bytes = new byte[256]; // insert code here}}
What is required at line 5 in class SomeApp to use the process method of BitUtils?
A. process(bytes);
B. BitUtils.process(bytes);
C. util.BitUtils.process(bytes);
D. SomeApp cannot use methods in BitUtils.
E. import util.BitUtils.*; process(bytes);
OCJP
www.javaexpert.co.in
Q. enum Example { ONE, TWO, THREE }
Which statement is true?
A. The expressions (ONE == ONE) and ONE.equals(ONE) are both guaranteed
to be true.
B. The expression (ONE < TWO) is guaranteed to be true and
ONE.compareTo(TWO) is guaranteed to be less than one.
C. The Example values cannot be used in a raw java.util.HashMap; instead, the
programmer must use a java.util.EnumMap.
D. The Example values can be used in a java.util.SortedSet, but the set will NOT
be sorted because enumerated types do NOT implement java.lang.Comparable.
OCJP
www.javaexpert.co.in
Q. public abstract class Shape {
private int x;
private int y;
public abstract void draw();
public void setAnchor(int x, int y) {
this.x = x; this.y = y;}}
Which two classes use the Shape class correctly?
A. public class Circle implements Shape { private int radius; }
B. public abstract class Circle extends Shape { private int radius; }
C. public class Circle extends Shape { private int radius; public void draw(); }
D. public class Circle extends Shape { private int radius; public void draw() {/* code here */}
E. public abstract class Circle implements Shape { private int radius; public void draw() { /* code
here */ }
OCJP
www.javaexpert.co.in
Q. class Nav{
public enum Direction { NORTH, SOUTH, EAST, WEST } }
public class Sprite{ // insert code here }
Which code, inserted at line 14, allows the Sprite class to compile?
A. Direction d = NORTH;
B. Nav.Direction d = NORTH;
C. Direction d = Direction.NORTH;
D. Nav.Direction d = Nav.Direction.NORTH;
OCJP
www.javaexpert.co.in
Q. int [] x = {1, 2, 3, 4, 5}; //Line 1
int y[] = x; // Line 2
System.out.println(y[2]); // Line 3
Which statement is true? // Line 4
A. Line 3 will print the value 2.
B. Line 3 will print the value 3.
C. Compilation will fail because of an error in line 1.
D. Compilation will fail because of an error in line 2.
OCJP
www.javaexpert.co.in

More Related Content

What's hot

Functional Programming 101 with Scala and ZIO @FunctionalWorld
Functional Programming 101 with Scala and ZIO @FunctionalWorldFunctional Programming 101 with Scala and ZIO @FunctionalWorld
Functional Programming 101 with Scala and ZIO @FunctionalWorldJorge Vásquez
 
Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple ProgramsUpender Upr
 
C# Variables and Operators
C# Variables and OperatorsC# Variables and Operators
C# Variables and OperatorsSunil OS
 
Implementing the IO Monad in Scala
Implementing the IO Monad in ScalaImplementing the IO Monad in Scala
Implementing the IO Monad in ScalaHermann Hueck
 
Composing an App with Free Monads (using Cats)
Composing an App with Free Monads (using Cats)Composing an App with Free Monads (using Cats)
Composing an App with Free Monads (using Cats)Hermann Hueck
 
Fnt software solutions placement paper
Fnt software solutions placement paperFnt software solutions placement paper
Fnt software solutions placement paperfntsofttech
 
Interface
InterfaceInterface
Interfacevvpadhu
 
All Aboard The Scala-to-PureScript Express!
All Aboard The Scala-to-PureScript Express!All Aboard The Scala-to-PureScript Express!
All Aboard The Scala-to-PureScript Express!John De Goes
 
Improving Android Performance at Droidcon UK 2014
Improving Android Performance at Droidcon UK 2014Improving Android Performance at Droidcon UK 2014
Improving Android Performance at Droidcon UK 2014Raimon Ràfols
 
One Monad to Rule Them All
One Monad to Rule Them AllOne Monad to Rule Them All
One Monad to Rule Them AllJohn De Goes
 
Operators
OperatorsOperators
Operatorsvvpadhu
 
Multiple choice questions for Java io,files and inheritance
Multiple choice questions for Java io,files and inheritanceMultiple choice questions for Java io,files and inheritance
Multiple choice questions for Java io,files and inheritanceAbishek Purushothaman
 
Java simple programs
Java simple programsJava simple programs
Java simple programsVEERA RAGAVAN
 
Scalaz 8 vs Akka Actors
Scalaz 8 vs Akka ActorsScalaz 8 vs Akka Actors
Scalaz 8 vs Akka ActorsJohn De Goes
 
The Design of the Scalaz 8 Effect System
The Design of the Scalaz 8 Effect SystemThe Design of the Scalaz 8 Effect System
The Design of the Scalaz 8 Effect SystemJohn De Goes
 
Juan josefumeroarray14
Juan josefumeroarray14Juan josefumeroarray14
Juan josefumeroarray14Juan Fumero
 

What's hot (20)

Functional Programming 101 with Scala and ZIO @FunctionalWorld
Functional Programming 101 with Scala and ZIO @FunctionalWorldFunctional Programming 101 with Scala and ZIO @FunctionalWorld
Functional Programming 101 with Scala and ZIO @FunctionalWorld
 
Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple Programs
 
C# Variables and Operators
C# Variables and OperatorsC# Variables and Operators
C# Variables and Operators
 
Implementing the IO Monad in Scala
Implementing the IO Monad in ScalaImplementing the IO Monad in Scala
Implementing the IO Monad in Scala
 
Composing an App with Free Monads (using Cats)
Composing an App with Free Monads (using Cats)Composing an App with Free Monads (using Cats)
Composing an App with Free Monads (using Cats)
 
Fnt software solutions placement paper
Fnt software solutions placement paperFnt software solutions placement paper
Fnt software solutions placement paper
 
7
77
7
 
Interface
InterfaceInterface
Interface
 
All Aboard The Scala-to-PureScript Express!
All Aboard The Scala-to-PureScript Express!All Aboard The Scala-to-PureScript Express!
All Aboard The Scala-to-PureScript Express!
 
&Y tgs P kii for
&Y tgs P kii for&Y tgs P kii for
&Y tgs P kii for
 
Yacf
YacfYacf
Yacf
 
Improving Android Performance at Droidcon UK 2014
Improving Android Performance at Droidcon UK 2014Improving Android Performance at Droidcon UK 2014
Improving Android Performance at Droidcon UK 2014
 
One Monad to Rule Them All
One Monad to Rule Them AllOne Monad to Rule Them All
One Monad to Rule Them All
 
Operators
OperatorsOperators
Operators
 
Multiple choice questions for Java io,files and inheritance
Multiple choice questions for Java io,files and inheritanceMultiple choice questions for Java io,files and inheritance
Multiple choice questions for Java io,files and inheritance
 
Java simple programs
Java simple programsJava simple programs
Java simple programs
 
Scalaz 8 vs Akka Actors
Scalaz 8 vs Akka ActorsScalaz 8 vs Akka Actors
Scalaz 8 vs Akka Actors
 
MTL Versus Free
MTL Versus FreeMTL Versus Free
MTL Versus Free
 
The Design of the Scalaz 8 Effect System
The Design of the Scalaz 8 Effect SystemThe Design of the Scalaz 8 Effect System
The Design of the Scalaz 8 Effect System
 
Juan josefumeroarray14
Juan josefumeroarray14Juan josefumeroarray14
Juan josefumeroarray14
 

Viewers also liked

LiveAdmins and Gitex 2016
LiveAdmins and Gitex 2016LiveAdmins and Gitex 2016
LiveAdmins and Gitex 2016LiveAdmins
 
Canada Employment and Labour market for November 2016 - Analysis and Commentary
Canada Employment and Labour market for November 2016 - Analysis and CommentaryCanada Employment and Labour market for November 2016 - Analysis and Commentary
Canada Employment and Labour market for November 2016 - Analysis and Commentarypaul young cpa, cga
 
Carpeta digital bertona arenas
Carpeta digital bertona arenasCarpeta digital bertona arenas
Carpeta digital bertona arenasErika Arenas
 
Google maps (equipo) (1)
Google maps (equipo) (1)Google maps (equipo) (1)
Google maps (equipo) (1)Lía Sánchez
 
Características basicas del voleibol
Características  basicas  del voleibolCaracterísticas  basicas  del voleibol
Características basicas del voleiboljoven10
 

Viewers also liked (9)

LiveAdmins and Gitex 2016
LiveAdmins and Gitex 2016LiveAdmins and Gitex 2016
LiveAdmins and Gitex 2016
 
Canada Employment and Labour market for November 2016 - Analysis and Commentary
Canada Employment and Labour market for November 2016 - Analysis and CommentaryCanada Employment and Labour market for November 2016 - Analysis and Commentary
Canada Employment and Labour market for November 2016 - Analysis and Commentary
 
PLANIFICADOR DE PROYECTOS
PLANIFICADOR DE PROYECTOSPLANIFICADOR DE PROYECTOS
PLANIFICADOR DE PROYECTOS
 
Carpeta digital bertona arenas
Carpeta digital bertona arenasCarpeta digital bertona arenas
Carpeta digital bertona arenas
 
Seminario 3
Seminario 3Seminario 3
Seminario 3
 
Google maps (equipo) (1)
Google maps (equipo) (1)Google maps (equipo) (1)
Google maps (equipo) (1)
 
Social marketing
Social marketingSocial marketing
Social marketing
 
Газета "Наш край", №12, 2-15 декабря, - русский
Газета "Наш край", №12, 2-15 декабря, - русскийГазета "Наш край", №12, 2-15 декабря, - русский
Газета "Наш край", №12, 2-15 декабря, - русский
 
Características basicas del voleibol
Características  basicas  del voleibolCaracterísticas  basicas  del voleibol
Características basicas del voleibol
 

Similar to Language fundamentals ocjp

Java ppt Gandhi Ravi (gandhiri@gmail.com)
Java ppt  Gandhi Ravi  (gandhiri@gmail.com)Java ppt  Gandhi Ravi  (gandhiri@gmail.com)
Java ppt Gandhi Ravi (gandhiri@gmail.com)Gandhi Ravi
 
Java Bytecode for Discriminating Developers - JavaZone 2011
Java Bytecode for Discriminating Developers - JavaZone 2011Java Bytecode for Discriminating Developers - JavaZone 2011
Java Bytecode for Discriminating Developers - JavaZone 2011Anton Arhipov
 
OCJP Samples Questions: Exceptions and assertions
OCJP Samples Questions: Exceptions and assertionsOCJP Samples Questions: Exceptions and assertions
OCJP Samples Questions: Exceptions and assertionsHari kiran G
 
Implementation of interface9 cm604.30
Implementation of interface9 cm604.30Implementation of interface9 cm604.30
Implementation of interface9 cm604.30myrajendra
 
Java Serialization
Java SerializationJava Serialization
Java Serializationjeslie
 
Java Generics
Java GenericsJava Generics
Java Genericsjeslie
 
Core Java- An advanced review of features
Core Java- An advanced review of featuresCore Java- An advanced review of features
Core Java- An advanced review of featuresvidyamittal
 
Indus Valley Partner aptitude questions and answers
Indus Valley Partner aptitude questions and answersIndus Valley Partner aptitude questions and answers
Indus Valley Partner aptitude questions and answersSushant Choudhary
 
Object Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsObject Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsMuhammadTalha436
 

Similar to Language fundamentals ocjp (20)

Core java Essentials
Core java EssentialsCore java Essentials
Core java Essentials
 
Java ppt Gandhi Ravi (gandhiri@gmail.com)
Java ppt  Gandhi Ravi  (gandhiri@gmail.com)Java ppt  Gandhi Ravi  (gandhiri@gmail.com)
Java ppt Gandhi Ravi (gandhiri@gmail.com)
 
Java concurrency questions and answers
Java concurrency questions and answers Java concurrency questions and answers
Java concurrency questions and answers
 
Nabil code
Nabil  codeNabil  code
Nabil code
 
Nabil code
Nabil  codeNabil  code
Nabil code
 
Nabil code
Nabil  codeNabil  code
Nabil code
 
Scjp6.0
Scjp6.0Scjp6.0
Scjp6.0
 
Java Bytecode for Discriminating Developers - JavaZone 2011
Java Bytecode for Discriminating Developers - JavaZone 2011Java Bytecode for Discriminating Developers - JavaZone 2011
Java Bytecode for Discriminating Developers - JavaZone 2011
 
Java 5 and 6 New Features
Java 5 and 6 New FeaturesJava 5 and 6 New Features
Java 5 and 6 New Features
 
OCJP Samples Questions: Exceptions and assertions
OCJP Samples Questions: Exceptions and assertionsOCJP Samples Questions: Exceptions and assertions
OCJP Samples Questions: Exceptions and assertions
 
Java Inheritance
Java InheritanceJava Inheritance
Java Inheritance
 
Unit-3 Practice Programs-5.docx
Unit-3 Practice Programs-5.docxUnit-3 Practice Programs-5.docx
Unit-3 Practice Programs-5.docx
 
Implementation of interface9 cm604.30
Implementation of interface9 cm604.30Implementation of interface9 cm604.30
Implementation of interface9 cm604.30
 
Interface
InterfaceInterface
Interface
 
Java Serialization
Java SerializationJava Serialization
Java Serialization
 
Java Generics
Java GenericsJava Generics
Java Generics
 
Core java
Core javaCore java
Core java
 
Core Java- An advanced review of features
Core Java- An advanced review of featuresCore Java- An advanced review of features
Core Java- An advanced review of features
 
Indus Valley Partner aptitude questions and answers
Indus Valley Partner aptitude questions and answersIndus Valley Partner aptitude questions and answers
Indus Valley Partner aptitude questions and answers
 
Object Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsObject Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ Exams
 

Recently uploaded

Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Quarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayQuarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayMakMakNepo
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 

Recently uploaded (20)

Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Quarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayQuarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up Friday
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"
 

Language fundamentals ocjp

  • 1. OCJP www.javaexpert.co.in Q. class Foo { static void alpha() { /*code here */ } void beta() { /*code here */ } } A. Foo.beta() is a valid invocation of beta(). B. Foo.alpha() is a valid invocation of alpha(). C. Method beta() can directly call method alpha(). D. Method alpha() can directly call method beta().
  • 2. OCJP www.javaexpert.co.in Q. public class demo { static public void main(String [] yahoo) { for(int x = 1; x < yahoo.length; x++) { System.out.print(yahoo[x] + " "); } } and the command line invocation: java demo a b c Output is : - A. b c B. a b c C. Compilation fails. D. An exception is thrown at runtime.
  • 3. OCJP www.javaexpert.co.in Q. public class Yippee { public static void main(String [] args) { for(int x = 1; x < args.length; x++) { System.out.print(args[x] + " "); }}} From command line java Yippee java Yippee 1 2 3 4 A. No output 1 2 3 4 B. No output 2 3 4 C. An exception is thrown at runtime. 2 3 4 D. An exception is thrown at runtime. 1 2 3 4
  • 4. OCJP www.javaexpert.co.in Q. package utils; public class Repetition { public static String twice(String s) { return s + s; } } and given another class Demo:// insert code here public class Demo { public static void main(String[] args) { System.out.println(twice("pizza"));}} Which code should be inserted at line 1 of Demo.java to compile and run Demo to print "pizzapizza"? A. import utils.*; B. static import utils.*; C. import utils.Repetition.*; D. static import utils.Repetition.*; E. import utils.Repetition.twice(); F. import static utils.Repetition.twice; G. static import utils.Repetition.twice;
  • 5. OCJP www.javaexpert.co.in Q. A JavaBeans component has the following field: private boolean enabled; Which two pairs of method declarations follow the JavaBeans standard for accessing this field? (select any two). A. public void setEnabled( boolean enabled ) public boolean getEnabled() B. public void setEnabled( boolean enabled ) public void isEnabled() C. public void setEnabled( boolean enabled ) public boolean isEnabled() D. public boolean setEnabled( boolean enabled ) public boolean getEnabled()
  • 6. OCJP www.javaexpert.co.in Q. package util; public class BitUtils { public static void process(byte[]) { /* more code here */ }} package app; public class SomeApp { public static void main(String[] args) { byte[] bytes = new byte[256]; // insert code here}} What is required at line 5 in class SomeApp to use the process method of BitUtils? A. process(bytes); B. BitUtils.process(bytes); C. util.BitUtils.process(bytes); D. SomeApp cannot use methods in BitUtils. E. import util.BitUtils.*; process(bytes);
  • 7. OCJP www.javaexpert.co.in Q. enum Example { ONE, TWO, THREE } Which statement is true? A. The expressions (ONE == ONE) and ONE.equals(ONE) are both guaranteed to be true. B. The expression (ONE < TWO) is guaranteed to be true and ONE.compareTo(TWO) is guaranteed to be less than one. C. The Example values cannot be used in a raw java.util.HashMap; instead, the programmer must use a java.util.EnumMap. D. The Example values can be used in a java.util.SortedSet, but the set will NOT be sorted because enumerated types do NOT implement java.lang.Comparable.
  • 8. OCJP www.javaexpert.co.in Q. public abstract class Shape { private int x; private int y; public abstract void draw(); public void setAnchor(int x, int y) { this.x = x; this.y = y;}} Which two classes use the Shape class correctly? A. public class Circle implements Shape { private int radius; } B. public abstract class Circle extends Shape { private int radius; } C. public class Circle extends Shape { private int radius; public void draw(); } D. public class Circle extends Shape { private int radius; public void draw() {/* code here */} E. public abstract class Circle implements Shape { private int radius; public void draw() { /* code here */ }
  • 9. OCJP www.javaexpert.co.in Q. class Nav{ public enum Direction { NORTH, SOUTH, EAST, WEST } } public class Sprite{ // insert code here } Which code, inserted at line 14, allows the Sprite class to compile? A. Direction d = NORTH; B. Nav.Direction d = NORTH; C. Direction d = Direction.NORTH; D. Nav.Direction d = Nav.Direction.NORTH;
  • 10. OCJP www.javaexpert.co.in Q. int [] x = {1, 2, 3, 4, 5}; //Line 1 int y[] = x; // Line 2 System.out.println(y[2]); // Line 3 Which statement is true? // Line 4 A. Line 3 will print the value 2. B. Line 3 will print the value 3. C. Compilation will fail because of an error in line 1. D. Compilation will fail because of an error in line 2.