473,505 Members | 13,925 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multiple choice questions..

37 New Member
hi,

i've been solving these multiple choice questions, and i'd like to know if what i answered is right ot wrong......... just to double check :)

I) Consider the code given below.

Expand|Select|Wrap|Line Numbers
  1.    class Base{} 
  2.     public class MyCast extends Base{ 
  3.         static boolean b1=false; 
  4.         static int i = ‐1; 
  5.         static double d = 10.1; 
  6.         public static void main(String argv[]){ 
  7.              MyCast m = new MyCast(); 
  8.              Base b = new Base(); 
  9.              //………..Here 
  10.     }} 
Which of the following, if inserted at the comment //Here will allow the code to compile and run without error
(a) b=m;
(b) m=b;
(c) d =i;
(d) b1 =i;

- chose (a) because a variable which is declared as a base class can also take instances of subclasses, whereas a variable that's declared as a subclass cannot be set to a superclass.


(II) Given the following variables which of the following lines will compile without error?
String s = "Hello";
long l = 99;
double d = 1.11;
int i = 1;
int j = 0;

(a) j= i <<s;
(b) j= i<<j;
(c) j=i<<d;
(d) j=i<<l;

- I chose (b) because you can't shift by a long, double, or a string.


thanks,

carly :D
Nov 4 '06 #1
1 19261
r035198x
13,262 MVP
hi,

i've been solving these multiple choice questions, and i'd like to know if what i answered is right ot wrong......... just to double check :)

I) Consider the code given below.

Expand|Select|Wrap|Line Numbers
  1. class Base{} 
  2. public class MyCast extends Base{ 
  3. static boolean b1=false; 
  4. static int i = ‐1; 
  5. static double d = 10.1; 
  6. public static void main(String argv[]){ 
  7. MyCast m = new MyCast(); 
  8. Base b = new Base(); 
  9. //………..Here 
  10. }} 
Which of the following, if inserted at the comment //Here will allow the code to compile and run without error
(a) b=m;
(b) m=b;
(c) d =i;
(d) b1 =i;

- chose (a) because a variable which is declared as a base class can also take instances of subclasses, whereas a variable that's declared as a subclass cannot be set to a superclass.


(II) Given the following variables which of the following lines will compile without error?
String s = "Hello";
long l = 99;
double d = 1.11;
int i = 1;
int j = 0;

(a) j= i <<s;
(b) j= i<<j;
(c) j=i<<d;
(d) j=i<<l;

- I chose (b) because you can't shift by a long, double, or a string.


thanks,

carly :D
For the first one, with a 1.5 compiler you also get
d =i; as valid. An integer can be stored in a double reference

For the second one, You can shifta long!
Nov 6 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
5050
by: raiya | last post by:
hi, I'm a teacher and new ms access user. I'm intending to design an ms access db to post multiple choice questions each with 4 choices. I created 2 tables one for the questions and the other for the...
0
1157
by: Night Air | last post by:
I have problem with a website that collects user responses to multiple choice questions. The users choose and value from a Radio Button, then click on a Next button to go the next page. The...
1
6109
by: Brian Byrne | last post by:
Hi , Does anybody know where there is a good bank of C++ multiple choice questions covering all the essentials. I need to brush up on the basics and multiple choice is the ideal way !? ...
1
1915
by: Night Air | last post by:
I'm working with a website that presents a series of multiple choice questions to users. The problem at hand is that the pages with the questions take some time load and the users are under a...
3
8989
mb60
by: mb60 | last post by:
hello I am working as teacher. Pl any one can help me in creating a template for multiple choice questions, and matching questions and selecting the answers in ms access? The format of qns as...
3
7770
by: shashkun | last post by:
hii i wanted to insert questions, options and correct answer in the database(Multiple choice questions). I have around 8000 questions to be inserted. I tried with copying entire content from word...
7
4209
mb60
by: mb60 | last post by:
sir In my database I have one column for question. Four columns are meant for options 1,2,3,4. The 5th column is YES/NO column. The answers for the questions are entered into 5th column by a...
0
7213
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7098
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7298
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7017
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5610
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4698
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3187
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
406
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.