• الصفحة الرئيسية
  • إتصل بنا
  • سياسة الخصوصية
Logo
  • الرئيسية
  • أفكار
  • صحة
  • معلومات
  • عجائب وغرائب
  • تكنولوجيا
الصفحة الرئيسية Java Multiple Choice Question (MCQ) MCQ on Java Programming With Answers set-11

MCQ on Java Programming With Answers set-11

الكاتب ahmed في 11:10 PM Java Multiple Choice Question (MCQ)

1. If m and n are int type variables, what will be the result of the expression m%n when m=-14 and n=-3?

A) 4

B) 2

C) -2

D) -4



2. Consider the following code

if(number>=0)

if(number>0)

system.out.println("Number is positive");

else

system.out.println("Number is negative");

What will be the output if number is equal to 0?

A) Number is negative

B) Number is positive

C) Both A and B

D) None of the above



3. Consider the following code:

char c='a';

switch (c)

{
case 'a';

system.out.println("A");

case 'b';

system.out.println("B");

default;



system.out.println("C");
}

For this code, which of the following statement is true?

A) Output will be A

B) Output will be A followed by B

C) Output will be A, followed by B, and then followed by C

D) Code is illegal and therefore will not compile



4. Consider the following class definition.

class Student extends String

{
}

What happens when we try to compile this class?


A) Will not compile because class body is not defined

B) Will not compile because the class in not declared public.

C) Will not compile because string is abstract.

D) Will not compile because string is final.



5. What is wrong in the following class definitions?

abstract class print

{
abstract show();
}
class Display extends Print
{
}

A) Nothing is wrong

B) Wrong. Method show() should have a return type

C) Wrong. Method show() is not implemented in Display

D) Wrong. Display does not contain any numbers.



6. What is the error in the following class definitions?

abstract class XY
{
abstract sum(int x, int y){ }
}

A) Class header is not defined properly

B) Constructor is not defined

C) Method is not defined properly

D) No error.




7. Which of the following statements are true?

i) We cannot use abstract classes to instantiate objects directly.

ii) The abstract methods of an abstract class must be defined in its subclass.

iii) We cannot declare abstract constructors.

iv) We may declare abstract static methods.

A) Line i only

B) Line ii only

C) Line i and ii only

D) Line i, ii and iii only




8. We would like to make a member of a class visible in all subclasses regardless of what package they are in. Which one of the following keywords would archive this?

A) Private

B) Protected

C) Public

D) Private Protected




9. The use of protected keyword to a member in a class will restrict its visibility as follows:

A) Visible only in the class and its subclass in the same package.

B) Visible only inside the same package.

C) Visible in all classes in the same package and subclasses in other packages

D) Visible only in the class where it is declared.




10. Consider the following code:

interface Area
{
float compute (float x, float y);
}
class Room implements Area
{
float compute (float x, float y)

{
return(x&y);
}
}

What is wrong with the code?

A) Interface definition is incomplete

B) Method compute() in interface Area should be declared public

C) Method compute() in class Room should be declared public

D) All the above






Answers:



1. If m and n are int type variables, what will be the result of the expression m%n when m=-14 and n=-3?

C) -2


2. Consider the following code

if(number>=0)
if(number>0)
system.out.println("Number is positive");
else
system.out.println("Number is negative");

What will be the output if number is equal to 0?

A) Number is negative


3. Consider the following code:

char c='a';
switch (c)
{
case 'a';
system.out.println("A");
case 'b';
system.out.println("B");
default;
system.out.println("C");
}

For this code, which of the following statement is true?

B) Output will be A followed by B


4. Consider the following class definition.

class Student extends String
{
}

What happens when we try to compile this class?

D) Will not compile because string is final.


5. What is wrong in the following class definitions?

abstract class print
{
abstract show();
}
class Display extends Print
{
}

C) Wrong. Method show() is not implemented in Display


6. What is the error in the following class definitions?

abstract class XY
{
abstract sum(int x, int y){ }
}


C) Method is not defined properly


7. Which of the following statements are true?

i) We cannot use abstract classes to instantiate objects directly.

ii) The abstract methods of an abstract class must be defined in its subclass.

iii) We cannot declare abstract constructors.

iv) We may declare abstract static methods.

D) Line i, ii and iii only


8. We would like to make a member of a class visible in all subclasses regardless of what package they are in. Which one of the following keywords would archive this?

D) Private Protected


9. The use of protected keyword to a member in a class will restrict its visibility as follows:

C) Visible in all classes in the same package and subclasses in other packages


10. Consider the following code:

interface Area
{
float compute (float x, float y);
}
class Room implements Area
{
float compute (float x, float y)
{
return(x&y);
}
}

What is wrong with the code?

C) Method compute() in class Room should be declared public




Related Posts



  • Solved MCQ of Java Set-1
  • MCQ of Java with answer set-2
  • Solved MCQ of Java for Java Proficiency test set-3
  • Solved MCQ of Java set-4
  • Java MCQ Questions and Answers set-5
  • Java Multiple Choice Questions With Answers set-6
  • MCQ of Java With Answer set-7
  • Java Multiple Choice Questions With Answers set-8
  • Solved MCQ of JDBC and JSP set-1
  • Solved MCQ of Java Beans set-1

For other more Multiple Choice Questions (MCQs): Click Here

شارك المقال :
Tweet
✚

مقالات ذات صلة

التالي
المشاركةالتالية
السابق
المشاركة السابقة

تحويل كودإخفاء محول الأكواد الإبتساماتإخفاء

شكرا لمشاركتنا رأيك
Subscribe to: Post Comments (Atom)
  • Facebook
  • twitter
  • googleplus
  • youtube
  • linkedin

الأكثر زيارة

  • What is Information ?
    Information  can be defined as data that has been processed into a form that is meaningful to the recipient and is of real or perceived valu...
  • What is Information Technology?
    Definitions of  Information technology  ( IT ) It is a branch of engineering dealing with the use of computers and telecommunications equipm...
  • بالصور الفائزة بمسابقة ملكة جمال مصر 2017
    بالصور الفائزة بمسابقة ملكة جمال مصر 2017
    بالصور الفائزة بمسابقة ملكة جمال مصر 2017 لن تصدق من هي فرح صدقي ↓↓  لمشاهدة الصور والخبر كامل اضغط هنا  ↓↓ رابط المو...
  • Interview Questions on Stack and Queue in Data Structure set-2
    1) The queue in which the insertion takes place in the first position after of last element is a ...... A. priority B. dequeue C. circular D...
  • List of Top 65 Search Engine Submission Add URLs.
    List of Top 65 Search Engine Submission Add URLs.
    To get your site on the top ranking on the search engine results, Your site or URL must be indexed by Search Engines. For that you have to s...
  • List of Best Keyword Research Tools for Better SEO
    List of Best Keyword Research Tools for Better SEO
    Everyone needs to do keyword research work for the site before starting search engine optimization work as the first and most essential tas...
  • What are the different types of scheduling methods?
    Process scheduling is one way for a processor to handle n processes , by scheduling the execution process. Each process is executed one by ...
  • Solved MCQ on Database Backup and Recovery in DBMS set-1
    1) Which of the following is not a recovery technique? A. Deferred update B. Immediate update C. Two-phase commit D. Recovery management 2)C...
  • Solved MCQ on Distributed Database Transaction Management set-4
    1) Commit and rollback are related to .......... A. data integrity B. data consistency C. data sharing D. data security 2) The transaction w...
  • Solved MCQ on Fundamental of DBMS set-10
    1) Which of the following is not a characteristic of a relational database model? A. Table B. Tree like structure C. Complex logical relatio...

الأقسام

  • Artificial Intelligence(AI)
  • Backlinking
  • Basic IT
  • Best List
  • Blogging Tips
  • C
  • C#
  • C++
  • Computer Architecture
  • Computer Fundamental
  • Computer Security
  • Computer/IT Officer Exam
  • CSS
  • Data Mining and Warehousing
  • Data Recovery Tools
  • Data Structure
  • Database Management System
  • E-commerce
  • E-government
  • Internet & Web Designing
  • IT Law
  • IT Tips and Tricks
  • IT Tutorials
  • Java
  • JavaScript
  • Keyword Research Tools
  • MIS
  • Multiple Choice Question (MCQ)
  • Networking
  • Online Earning
  • Online IT Jobs
  • Operating System
  • Oracle Forms and Reports
  • Programming Guide
  • Programming Language
  • SEO
  • Social Networking Sites
  • Software Download
  • Software Engineering
  • System Analysis and Design
  • Top List
  • VB.Net
  • صحة
  • عجائب وغرائب

الأرشيف

  • ►  2017 (4)
    • ►  November (3)
    • ►  October (1)
  • ►  2016 (5)
    • ►  April (5)
  • ►  2015 (87)
    • ►  August (1)
    • ►  July (8)
    • ►  June (13)
    • ►  May (2)
    • ►  April (2)
    • ►  March (4)
    • ►  February (20)
    • ►  January (37)
  • ▼  2014 (77)
    • ►  December (31)
    • ►  November (4)
    • ►  September (4)
    • ►  August (11)
    • ▼  July (8)
      • MCQ on Java Programming With Answers set-11
      • Write a Program in C to Find if a Number is Presen...
      • C Program to Find the Sum and Average of Numbers U...
      • Write a Program in C to Sort a List of Numbers in ...
      • Write a Program in C to Calculate the Factorial Va...
      • Write a Program in C to Copy a String to Another.
      • C Program to Read Set of Real Numbers from Keyboar...
      • Write a Program in C to Determine Whether a Number...
    • ►  June (2)
    • ►  May (2)
    • ►  April (2)
    • ►  March (2)
    • ►  February (7)
    • ►  January (4)
  • ►  2013 (132)
    • ►  December (11)
    • ►  November (6)
    • ►  October (4)
    • ►  September (6)
    • ►  August (16)
    • ►  July (9)
    • ►  June (9)
    • ►  May (12)
    • ►  April (13)
    • ►  March (23)
    • ►  February (6)
    • ►  January (17)
  • ►  2012 (59)
    • ►  December (15)
    • ►  November (20)
    • ►  October (21)
    • ►  September (3)

إنضم لنا

© 2017 أفكار جميع الحقوق محفوظة