Sie sind auf Seite 1von 10

0) Introduction

Magik supports both procedural language and object oriented language.


Procedural Language:
In procedural language all code is in modular fashion. Each module is a collecti
on of statements. Module takes input and executes all statements step by step an
d gives output.
EX:
area << _proc @area(radius)
#code to calculate area
>> pi*radius * radius
_endproc
In the above example ,procedure is taking radius as input and returning the circ
le area as output value.
If we want to calculate area of square again we have to write on
e more procedure with different procedure name, though the purpose of the proced
ure is to calculate area.
In procedural language, maintenance is headache. We can overcome
this in oop language.
Object Oriented Programming Language:
In oop, both data and functionality is combined in a class. We c
an write methods with same name in different classes.
For example ,we can write method area() in different classes. Me
thods are accessed via their class name.
Ex:
Circle Class:
def_slotted_exemplar(:circle,
{})
$
_method circle.new()
>> _clone.init()
_endmethod
$
_method circle.init()
_return _self
_endmethod
$
_method circle.area(r)
area << 22/7*r*r
_return area.as_float
_endmethod
Sqaure class:
def_slotted_exemplar(:square,
{})
$
_method square.new()
>> _clone.init()
_endmethod
$
_method square.init()
_return _self
_endmethod
$
_method square.area(r)
area << r*r
_return area

_endmethod
To access area method in circle class,type circle.area(2) at mag
iksf prompt as shown below
MagikSF> circle.area(2)
$
12.57142857
ALL INTER VIEW QUESTIONS
Which method is used to generate id value?
make_sysid().
Posted by shreeLakshmi Poluru at 09:07 Email ThisBlogThis!Share to TwitterShare
to FacebookShare to Pinterest
Labels: interview questions, Magik, smallworld
How to add enumerators values without using the case tool?
Using extensible enumerator.
Posted by shreeLakshmi Poluru at 09:06 Email ThisBlogThis!Share to TwitterShare
to FacebookShare to Pinterest
Labels: interview questions, Magik, smallworld
How can we add indices to collection using magik code?
Add_index() and drop_index() methods are used to add and remove indices from col
lection.
Posted by shreeLakshmi Poluru at 09:05 Email ThisBlogThis!Share to TwitterShare
to FacebookShare to Pinterest
Labels: interview questions, Magik, smallworld
What is the difference between the detached record and template record?
Both detached record and template record returns an object which has same fields
and behavior of collection record but it is not an element of collection.
In detached record ,fields are not initialized with default value whereas in tem
plate record fields are initialized with default values.
Creating detached record is faster than the template record.
Posted by shreeLakshmi Poluru at 09:04 Email ThisBlogThis!Share to TwitterShare
to FacebookShare to Pinterest
Labels: interview questions, Magik, smallworld
Elements() vs fast_elements()
Elements() returns only valid records.
If we are using fast_elements() on the collection in which the records are inser
ting and deleting, then fast_elements() returns the deleted records also.
Posted by shreeLakshmi Poluru at 09:03 Email ThisBlogThis!Share to TwitterShare
to FacebookShare to Pinterest
Labels: interview questions, Magik, smallworld
When do we get stale record handle?
If user tries to refer the deleted object, then stale record handle error will ra
ises.
Posted by shreeLakshmi Poluru at 09:01 Email ThisBlogThis!Share to TwitterShare
to FacebookShare to Pinterest
Labels: interview questions, Magik, smallworld
smallworld database is which type of database?
Smallworld database is relational databse.
Posted by shreeLakshmi Poluru at 09:00 Email ThisBlogThis!Share to TwitterShare
to FacebookShare to Pinterest
Labels: interview questions, Magik, smallworld
Thursday, 19 February 2015
What are the different kinds of objects available in magik?
In Magik there are distinct formats for different kinds of object:
enumerated: objects that have no data, such as integers and Booleans
indexed: objects that have numbered elements
slotted: objects with named fields called slots

Posted by shreeLakshmi Poluru at 09:42 Email ThisBlogThis!Share to TwitterShare


to FacebookShare to Pinterest
Labels: interview questions, Magik, smallworld
How to generate magik compile file?
Magik compile file is generated using following command
magik_rep.compile_file(file_path )
<file_path>: give file full path
EX:
magik_rep.compile_file( D:\test.magik )
After executing the above statement test.magikc file is generated in the D:\
Posted by shreeLakshmi Poluru at 09:35 Email ThisBlogThis!Share to TwitterShare
to FacebookShare to Pinterest
Labels: interview questions, Magik, smallworld
Tuesday, 17 February 2015
Interview Questions
Smallworld application supports which n-tier architecture?
Name some executable files present in product bin directory? is user has direct
access to these files?
Which executable file is used to start a session on windows?
Posted by shreeLakshmi Poluru at 08:47 Email ThisBlogThis!Share to TwitterShare
to FacebookShare to Pinterest
Labels: interview questions, Magik, smallworld
Monday, 16 February 2015
Name some executable files present in product bin directory? is user has direct
access to these files?
Sw_magik,sw_magik_win32,swdocopen,swsleep etc.,
Yes, user has direct access to these files.
Posted by shreeLakshmi Poluru at 08:36 Email ThisBlogThis!Share to TwitterShare
to FacebookShare to Pinterest
Labels: Magik, smallworld
Which executable file is used to start a session on windows?
Sw_magik_win32 is used to start a session with graphics on the windows.
Along with this, there are other two executable files.
1. sw_magik for a session with no graphics.
2. sw_magik_motif for a session with graphics via the motif window system on uni
x computers.
Posted by shreeLakshmi Poluru at 08:34 Email ThisBlogThis!Share to TwitterShare
to FacebookShare to Pinterest
Labels: Magik, smallworld
Smallworld application supports which n-tier architecture?
Smallworld application supports 3-tier architecture.
1.
Database server layer
2.
Application engine layer.
3.
User interface layer.
Posted by shreeLakshmi Poluru at 08:33 Email ThisBlogThis!Share to TwitterShare
to FacebookShare to Pinterest
Labels: Magik, smallworld
Wednesday, 11 February 2015
Method Definitions
Functionality of the objects are defined in the methods. Methods are invoked by
sending message to the objects.
Methods can be defined in the following forms:

Standard method definition:


[_private]
_method <receiver> . <message> [ (<arguments>) ]
<block body>
_endmethod
<receiver> is the name of the class. <message> is the name of the method. <argum
ents> is the list of arguments.
If the keyword _private is present, that method can be accessed within the same
class and subclasses.
EX:
_method integer.odd_even()
_if _self.odd?
_then write("This is an odd number")
_else write("This is an even number")
_endif
_endmethod
Method with brackets is different from the same method name without brackets.
Odd_even() is different from odd_even.
Field Access method definition:
[_private]
_method <receiver> . <message>
<block body>
_endmethod
<receiver> is the name of the class. <message> is the name of the method.
EX:
_method association.key
>> .key
_endmethod
Usually,field access methods are used to return slot value.
Indexing method definitions:
[_private] _method <receiver>'[' <argument list> ']'
<block body>
_endmethod
<receiver> is the name of the class.
EX:
_method array_2[n]
...
_endmethod
Abstract Method:
_abstract _method <receiver> . <message> [ (<arguments>) ]
_endmethod

EX:
_abstract _method hash_helper.match?(thing1, thing2)
## Returns a boolean which is true if thing1 and thing2 should
## be regarded as the same
## Subclasses must provide an implementation of this method
_endmethod

Subclasses must implement abstract method otherwise error will raise.


Posted by shreeLakshmi Poluru at 09:40 Email ThisBlogThis!Share to TwitterShare
to FacebookShare to Pinterest
Labels: Magik, Procedure, smallworld
Procedure Definitions
Procedure is a collection of statements. Procedure invocation is simply calling
the procedure with its arguments. Procedure can also be invoked by sending invok
e() message on the procedure object.
EX: quit() or quit.invoke()
Procedure Syntax:
_proc [@ <identifier>] ( [<arguments>] )
<block body>
_endproc
@identifier and arguments are optional.
@identifier is useful to identify the procedure.
Note that the brackets ( ) are required, even if a procedure has no argu
ments.
Defining Procedure with identifier:
hello << _proc @greet()
write("Hello World")
_endproc
Procedure with name greet is created and is assigned to the
variable hello.
Procedure is invoked by hello() or hello.invoke().
Defining procedure and assigning to _global _constant variable:
_global _constant Hi << _proc()
write("I have name")
_endproc
Procedure is defined and assigned to the global constant var
iable hi. In this case procedure is named with constant name.

Defining procedure without identifier:


Hi << _proc()
write("I have no name")
_endproc
Unnamed procedure is created and is assigned to the variable hi.
Posted by shreeLakshmi Poluru at 09:28 Email ThisBlogThis!Share to TwitterShare
to FacebookShare to Pinterest
Labels: Magik, Procedure, smallworld
Tuesday, 10 February 2015
Introduction
Magik supports both procedural language and object oriented language.
Procedural Language:
In procedural language all code is in modular fashion. Each module is a collecti
on of statements. Module takes input and executes all statements step by step an
d gives output.
EX:
area << _proc @area(radius)
#code to calculate area
>> pi*radius * radius
_endproc
In the above example ,procedure is taking radius as input and returning the circ
le area as output value.
If we want to calculate area of square again we have to write on
e more procedure with different procedure name, though the purpose of the proced
ure is to calculate area.
In procedural language, maintenance is headache. We can overcome
this in oop language.
Object Oriented Programming Language:
In oop, both data and functionality is combined in a class. We c
an write methods with same name in different classes.
For example ,we can write method area() in different classes. Me
thods are accessed via their class name.
Ex:
Circle Class:
def_slotted_exemplar(:circle,
{})
$
_method circle.new()
>> _clone.init()
_endmethod
$
_method circle.init()
_return _self
_endmethod
$
_method circle.area(r)
area << 22/7*r*r
_return area.as_float
_endmethod
Sqaure class:

def_slotted_exemplar(:square,
{})
$
_method square.new()
>> _clone.init()
_endmethod
$
_method square.init()
_return _self
_endmethod
$
_method square.area(r)
area << r*r
_return area
_endmethod
To access area method in circle class,type circle.area(2) at mag
iksf prompt as shown below
MagikSF> circle.area(2)
$
12.57142857
1 What are the different kinds of objects available in magik?
In Magik there are distinct formats for different kinds of object:
enumerated: objects that have no data, such as integers and Booleans
indexed: objects that have numbered elements
slotted: objects with named fields called slots
2)What are the different kinds of objects available in magik?
In Magik there are distinct formats for different kinds of object:
enumerated: objects that have no data, such as integers and Booleans
indexed: objects that have numbered elements
slotted: objects with named fields called slots
3) How to generate magik compile file?
Magik compile file is generated using following command
magik_rep.compile_file(file_path )
<file_path>: give file full path
EX:
magik_rep.compile_file( D:\test.magik )
After executing the above statement test.magikc file is generated in the D:\
4) Name some executable files present in product bin directory? is user has dire
ct access to these files?
Sw_magik,sw_magik_win32,swdocopen,swsleep etc.,
Yes, user has direct access to these files
5) Which executable file is used to start a session on windows?
Sw_magik_win32 is used to start a session with graphics on the windows.
Along with this, there are other two executable files.
1. sw_magik for a session with no graphics.
2. sw_magik_motif for a session with graphics via the motif window system on uni

x computers.
6) Smallworld application supports which n-tier architecture?
Smallworld application supports 3-tier architecture.
1.
Database server layer
2.
Application engine layer.
3.
User interface layer.
6) Method Definitions
Functionality of the objects are defined in the methods. Methods are invoked by
sending message to the objects.
Methods can be defined in the following forms:
Standard method definition:
[_private]
_method <receiver> . <message> [ (<arguments>) ]
<block body>
_endmethod
<receiver> is the name of the class. <message> is the name of the method. <argum
ents> is the list of arguments.
If the keyword _private is present, that method can be accessed within the same
class and subclasses.
EX:
_method integer.odd_even()
_if _self.odd?
_then write("This is an odd number")
_else write("This is an even number")
_endif
_endmethod
Method with brackets is different from the same method name without brackets.
Odd_even() is different from odd_even.
Field Access method definition:
[_private]
_method <receiver> . <message>
<block body>
_endmethod
<receiver> is the name of the class. <message> is the name of the method.
EX:
_method association.key
>> .key
_endmethod
Usually,field access methods are used to return slot value.
Indexing method definitions:
[_private] _method <receiver>'[' <argument list> ']'
<block body>
_endmethod

<receiver> is the name of the class.


EX:
_method array_2[n]
...
_endmethod
Abstract Method:
_abstract _method <receiver> . <message> [ (<arguments>) ]
_endmethod
EX:
_abstract _method hash_helper.match?(thing1, thing2)
## Returns a boolean which is true if thing1 and thing2 should
## be regarded as the same
## Subclasses must provide an implementation of this method
_endmethod

Subclasses must implement abstract method otherwise error will raise


7) Procedure Definitions
Procedure is a collection of statements. Procedure invocation is simply calling
the procedure with its arguments. Procedure can also be invoked by sending invok
e() message on the procedure object.
EX: quit() or quit.invoke()
Procedure Syntax:
_proc [@ <identifier>] ( [<arguments>] )
<block body>
_endproc
@identifier and arguments are optional.
@identifier is useful to identify the procedure.
Note that the brackets ( ) are required, even if a procedure has no argu
ments.
Defining Procedure with identifier:
hello << _proc @greet()
write("Hello World")
_endproc

Procedure with name greet is created and is assigned to the


variable hello.
Procedure is invoked by hello() or hello.invoke().
Defining procedure and assigning to _global _constant variable:
_global _constant Hi << _proc()
write("I have name")
_endproc
Procedure is defined and assigned to the global constant var
iable hi. In this case procedure is named with constant name.
Defining procedure without identifier:
Hi << _proc()
write("I have no name")
_endproc
Unnamed procedure is created and is assigned to the variable hi.

Das könnte Ihnen auch gefallen